import { Temporal } from "temporal-spec";

//#region src/RRuleTemporal.d.ts
declare const allowedFreq: readonly ["YEARLY", "MONTHLY", "WEEKLY", "DAILY", "HOURLY", "MINUTELY", "SECONDLY"];
type Freq = (typeof allowedFreq)[number];
declare const allowedWeekdays: readonly ["MO", "TU", "WE", "TH", "FR", "SA", "SU"];
type Weekday = (typeof allowedWeekdays)[number];
declare const weekdayToIsoDay: Record<Weekday, number>;
/**
 * Shared options for all rule constructors.
 */
interface BaseOpts<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDateTime> {
  /** Temporal implementation used to construct public occurrence values. */
  temporal?: TemporalImplementation<TOutput>;
  /** Time zone identifier as defined in RFC&nbsp;5545 §3.2.19. */
  tzid?: string;
  /** Safety cap for advancing outer recurrence periods. */
  maxIterations?: number;
  /** Safety cap for candidate datetimes evaluated inside recurrence periods. */
  maxCandidateEvaluations?: number;
  /** Include DTSTART as an occurrence even if it does not match the rule pattern. */
  includeDtstart?: boolean;
  /** Enforce RFC 5545 constraints strictly (defaults to false). */
  strict?: boolean;
  /** RSCALE per RFC 7529: calendar system for recurrence generation (e.g., GREGORIAN). */
  rscale?: string;
  /** SKIP behavior per RFC 7529: OMIT (default), BACKWARD, FORWARD (requires RSCALE). */
  skip?: 'OMIT' | 'BACKWARD' | 'FORWARD';
  /** Memoize the full occurrence list computed by all() (defaults to true). */
  cache?: boolean;
}
type TemporalZonedDateTime = Temporal.ZonedDateTime;
type TemporalPlainDate = Temporal.PlainDate;
interface TemporalZonedDateTimeInput {
  readonly timeZoneId: string;
  toString(): string;
}
interface TemporalPlainDateInput {
  toString(): string;
}
/**
 * The subset of a Temporal namespace needed to construct public occurrence
 * values. Supplying an implementation makes output values and their inferred
 * TypeScript types come from that implementation.
 */
interface TemporalImplementation<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDateTime> {
  readonly ZonedDateTime: {
    from(value: string): TOutput;
  };
}
type RRuleTemporalIterator<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDateTime> = (date: TOutput, i: number) => boolean;
type DateFilter = Date | TemporalZonedDateTimeInput;
/**
 * Manual rule definition following the recurrence rule parts defined in
 * RFC 5545 §3.3.10.
 */
interface ManualOptions<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDateTime> extends BaseOpts<TOutput> {
  /** FREQ: recurrence frequency */
  freq: Freq;
  /** INTERVAL between each occurrence of {@link freq} */
  interval?: number;
  /** COUNT: total number of occurrences */
  count?: number;
  /** UNTIL: last possible occurrence */
  until?: TemporalZonedDateTimeInput;
  /** BYHOUR: hours to include (0-23) */
  byHour?: number[];
  /** BYMINUTE: minutes to include (0-59) */
  byMinute?: number[];
  /** BYSECOND: seconds to include (0-59) */
  bySecond?: number[];
  /** BYDAY: list of weekdays e.g. ["MO","WE","FR"] */
  byDay?: string[];
  /** BYMONTH: months of the year (1-12). With RSCALE (RFC 7529) may contain values like "5L". */
  byMonth?: Array<number | string>;
  /** BYMONTHDAY: days of the month (1..31 or negative from end) */
  byMonthDay?: number[];
  /** BYYEARDAY: days of the year (1..366 or negative from end) */
  byYearDay?: number[];
  /** BYWEEKNO: ISO week numbers (1..53 or negative from end) */
  byWeekNo?: number[];
  /** BYSETPOS: select n-th occurrence(s) after other filters */
  bySetPos?: number[];
  /** WKST: weekday on which the week starts ("MO".."SU") */
  wkst?: string;
  /** RDATE: additional dates to include */
  rDate?: TemporalZonedDateTimeInput[];
  /** EXDATE: exception dates to exclude */
  exDate?: TemporalZonedDateTimeInput[];
  /** DTSTART: first occurrence */
  dtstart: TemporalZonedDateTimeInput;
}
interface IcsOptions<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDateTime> extends BaseOpts<TOutput> {
  rruleString: string;
  dtstart?: TemporalZonedDateTimeInput;
  /** COUNT: total number of occurrences, used when missing from rruleString */
  count?: number;
  /** UNTIL: last possible occurrence, used when missing from rruleString */
  until?: TemporalZonedDateTimeInput;
  /** RDATE: additional dates to include */
  rDate?: TemporalZonedDateTimeInput[];
  /** EXDATE: exception dates to exclude */
  exDate?: TemporalZonedDateTimeInput[];
}
type RRuleOptions<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDateTime> = ManualOptions<TOutput> | IcsOptions<TOutput>;
type RRuleResolvedOptions<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDateTime> = Omit<ManualOptions<TOutput>, 'dtstart' | 'until' | 'rDate' | 'exDate'> & {
  dtstart: TOutput;
  until?: TOutput;
  rDate?: TOutput[];
  exDate?: TOutput[];
};
declare class RRuleTemporal<TOutput extends TemporalZonedDateTimeInput = TemporalZonedDateTime> {
  private readonly tzid;
  private readonly originalDtstart;
  private originalPlainDtstart?;
  private readonly opts;
  private readonly outputTemporal?;
  private readonly maxIterations;
  private readonly maxCandidateEvaluations;
  private readonly includeDtstart;
  private readonly parsedByDayTokens?;
  private readonly simpleByDayIsoDays?;
  private readonly allByDayIsoDays?;
  private readonly hasOrdinalByDay;
  private readonly canUseEpochMillisecondsPrecisionFlag;
  private readonly timeSlotOffsetsMs?;
  private readonly hasUniqueTimeSlotOffsets;
  private readonly numericByMonths?;
  private exDateEpochNs?;
  private numericRDatesCache?;
  private allResultCache?;
  private publicAllResultCache?;
  private outputConstructorFastPathAvailable?;
  private zoneResolver?;
  private emitAnchorZdt?;
  private numericQueryPlanCache;
  private periodQueryPlanCache;
  private dtstartIsOccurrenceCache?;
  private static readonly rscaleCalendarSupport;
  /**
   * Normalize a ZonedDateTime to the polyfill implementation.
   * This prevents type mismatches when mixing native and polyfill Temporal objects.
   */
  private static normalizeToPolyfill;
  private toPublicDate;
  private toPublicDates;
  constructor(params: RRuleOptions<TOutput>);
  private buildParsedByDayTokens;
  private buildByDayIsoDays;
  private sanitizeNumericArray;
  private sanitizeByDay;
  private enforceStrictRfc;
  private sanitizeOpts;
  private rawAdvance;
  /**  Expand one base ZonedDateTime into all BYHOUR × BYMINUTE × BYSECOND
   *  combinations, keeping chronological order. If the options are not
   *  present the original date is returned unchanged.
   */
  private expandByTime;
  private localDateKey;
  private sortedUniqueDateCandidates;
  /** Resolve generated wall time only after date expansion. RFC 5545 omits
   * nonexistent local times; compatible disambiguation is still used for
   * explicit DTSTART/RDATE inputs and the first occurrence of a repeated time.
   */
  private resolveGeneratedTime;
  private get generationTimeZone();
  private timeOfDayNanoseconds;
  private timeSlotNanoseconds;
  /**
   * On transition dates an explicit DTSTART may refer to the later fold while
   * other generated slots select the earlier fold. Resolve and sort at most
   * one day of slots so iteration and BYSETPOS follow actual instant order.
   */
  private needsSortedTimeFallback;
  private createCandidateWorkBudget;
  private recordCandidateEvaluation;
  /**
   * Visit BYHOUR x BYMINUTE x BYSECOND without allocating the Cartesian
   * product. Returning false from `visit` terminates the innermost traversal
   * immediately. The optional bounds are only supplied for the same local
   * calendar date by `visitDateTimeCandidates`.
   */
  private visitTimeSlots;
  private visitDateTimeCandidates;
  /** Apply BYSETPOS with bounded forward/reverse passes over one period. */
  private visitPeriodCandidates;
  /**
   * In UTC, calendar days and sorted time slots form an ordered Cartesian
   * product. Select positions and clip query bounds on integers, constructing
   * Temporal values only for the candidates the visitor actually consumes.
   * Keep the general visitor's work accounting, including both BYSETPOS passes.
   */
  private visitUtcPeriodCandidates;
  private nextCandidateSameDate;
  /**
   * Re-asserts the time of day an occurrence is supposed to have.
   *
   * A BYxxx part wins where one is given. Where none is, RFC 5545 3.3.10 takes the value from
   * DTSTART, so that is what gets restored here -- the same fallback the candidate generators
   * already apply (`this.opts.byHour ?? [this.originalDtstart.hour]`).
   *
   * Restoring it matters because advancing a cursor across a spring-forward gap moves the wall
   * time: 02:30 + 1 day lands on a time that does not exist and `compatible` disambiguation
   * resolves it to 03:30. Without re-asserting DTSTART's time, that shifted time is what the next
   * advance builds on, so every later occurrence in the series keeps it.
   *
   * Only fields the frequency does not own are pinned: HOURLY advances the hour, MINUTELY the
   * minute, SECONDLY the second, so those are left alone.
   */
  private applyTimeOverride;
  private computeFirst;
  private matchesByDay;
  private matchesByMonth;
  private matchesNumericConstraint;
  private matchesByMonthDay;
  private matchesByHour;
  private matchesByMinute;
  private matchesBySecond;
  private matchesAll;
  private matchesByYearDay;
  /**
   * The day of the year that negative BYYEARDAY values count back from: the
   * end of month 12. Calendars with a 13th month end later, so code that
   * seeks year days must use this rather than daysInYear to agree with
   * matchesByYearDay.
   */
  private lastByYearDay;
  private getIsoWeekInfo;
  private matchesByWeekNo;
  /**
   * Gregorian weekday and leap-year patterns repeat every 400 years. Checking
   * a complete cycle lets impossible BYYEARDAY + BYWEEKNO intersections stop
   * without incorrectly judging the rule from DTSTART's year alone.
   */
  private hasPossibleYearDayWeekNoCombination;
  options(): RRuleResolvedOptions<TOutput>;
  private cloneOptions;
  private cloneUpdateOptions;
  /**
   * Create a new {@link RRuleTemporal} instance with modified options while keeping the current one unchanged.
   *
   * @example
   * ```ts
   * const updated = rule.with({byMonthDay: [3]});
   * ```
   */
  with(updates: Partial<ManualOptions<TOutput>>): RRuleTemporal<TOutput>;
  /**
   * Whether the rule itself generates DTSTART, so includeDtstart must not add
   * it again. The BYxxx filters decide this unless BYSETPOS is present: it can
   * skip a DTSTART that every filter accepts, as a last-Friday rule skips any
   * other Friday. Then the rule, generated without includeDtstart, must start
   * at DTSTART.
   */
  private dtstartIsOccurrence;
  private addDtstartIfNeeded;
  private canUseUtcLinearFastPath;
  private canUseUtcWeeklyFastPath;
  private canUseUtcMonthlyFastPath;
  private utcZdtFromEpochNanoseconds;
  private utcZdtFromEpochMilliseconds;
  private canUseUtcCalendarFastPaths;
  private canUseUtcEpochMillisecondsPrecision;
  private buildTimeSlotOffsetsMs;
  private createNumericQueryPlan;
  private buildFixedStepNumericQueryPlan;
  private resolveNumericWallMilliseconds;
  private numericQueryGapHazard;
  private buildDailyNumericQueryPlan;
  private buildWeeklyNumericQueryPlan;
  private buildMonthlyNumericQueryPlan;
  /**
   * Build one Gregorian recurrence year's matching epoch days, without time
   * expansion. This deliberately covers the common YEARLY shapes
   * whose calendar membership repeats on the 400-year Gregorian cycle.
   */
  private generateYearlyOccurrenceDaysUtc;
  private generateYearlyOccurrenceEpochsUtc;
  private yearlyCandidateEvaluationCountUtc;
  private buildYearlyNumericQueryPlan;
  private buildNumericQueryPlan;
  private getNumericQueryPlan;
  /**
   * Build the period plan for a rule without COUNT. Eligibility mirrors the
   * COUNT plans above, and periods reuse their calendar generators.
   */
  private buildPeriodQueryPlan;
  private getPeriodQueryPlan;
  private findFirstMatchingDailyStep;
  private allUtcFastPath;
  private _allUtcFixedStepSimple;
  private _allUtcDailySimple;
  private _allUtcDailyExpanded;
  private _allUtcWeeklySimple;
  private _allUtcWeeklyExpanded;
  private hasSingleExpandedTimeSlot;
  private buildMonthlyOccurrenceOnDay;
  private applyBySetPosToSortedList;
  private generateMonthlyOccurrenceDays;
  private isGregorianLeapYear;
  private daysInGregorianMonth;
  private gregorianIsoDayOfWeek;
  private monthIndexToYearMonth;
  private generateMonthlyOccurrenceDaysUtc;
  private generateMonthlyOccurrenceEpochsUtc;
  private _allUtcMonthlyByDayOrMonthDay;
  private getZoneResolver;
  private zdtFromEpochMs;
  /** Local wall-clock ms (as-if-UTC) of a ZonedDateTime with ms precision. */
  private wallMsOf;
  private canUseTzEpochFastPaths;
  /**
   * True if the rule's nominal time of day can be skipped by a DST gap
   * anywhere in the (estimated) iteration range. Conservatively keep these
   * rules on the general engine, which omits invalid slots before BYSETPOS and COUNT.
   */
  private tzFastPathGapHazard;
  /**
   * An upper bound on the wall-clock span from DTSTART to the last of the
   * first `count` occurrences the DAILY and WEEKLY TZ fast paths emit, or
   * undefined when none is known. Each allows a period of candidates before DTSTART.
   */
  private tzFastPathCountSpanMs;
  private allTzEpochFastPath;
  private _allTzDailySimple;
  private _allTzDailyExpanded;
  private _allTzFixedStepSimple;
  private _allTzWeeklySimple;
  private _allTzWeeklyExpanded;
  private _allTzMonthlyByDayOrMonthDay;
  private processOccurrences;
  /** Process one occurrence and report whether generation should continue. */
  private processOccurrence;
  /**
   * Returns all occurrences of the rule.
   * @param iterator - An optional callback iterator function that can be used to filter or modify the occurrences.
   * @returns An array of Temporal.ZonedDateTime objects representing all occurrences of the rule.
   */
  private _allMonthlyByDayOrMonthDay;
  private _allWeekly;
  private _allYearlyComplex;
  private _allMinutelySecondlyComplex;
  private _allMonthlyByWeekNo;
  private _allMonthlyByYearDay;
  private _allDailyMinutelyHourlyWithBySetPos;
  private _allFallback;
  /**
   * HOURLY, MINUTELY, and SECONDLY rules with BYxxx parts (RFC 5545 3.3.10).
   * Periods begin at DTSTART + k * INTERVAL units in exact time, the set the
   * rule has without BYxxx parts (HOURLY;INTERVAL=1 visits a repeated wall hour
   * once, as rawAdvance() does). Parts at or above the frequency's own unit
   * limit which periods occur; BYMINUTE/BYSECOND below it expand a period, and
   * BYSETPOS selects within each period. A period outside the limits jumps to
   * the first period of the next window that can satisfy them.
   */
  private _allSubDailyPeriods;
  private matchesSubDailyDate;
  /** A later date that may satisfy the date-level parts; none before it can. */
  private nextSubDailyDateCandidate;
  /** Calendar periods advance independently of the dates and times they emit.
   * Invalid inherited dates and nonexistent wall times do not consume COUNT
   * or change DTSTART's fields for the following period (RFC 5545 3.3.10).
   */
  private _allCalendarPeriods;
  /**
   * Returns all occurrences of the rule.
   * @param iterator - An optional callback iterator function that can be used to filter or modify the occurrences.
   * @returns An array of Temporal.ZonedDateTime objects representing all occurrences of the rule.
   */
  all(iterator?: RRuleTemporalIterator<TOutput>): TOutput[];
  private allInternal;
  /**
   * Converts rDate entries to ZonedDateTime and merges with existing dates.
   * @param dates - Array of dates to merge with
   * @returns Merged and deduplicated array of dates
   */
  private mergeAndDeduplicateRDates;
  /**
   * Checks if a date is in the exDate list.
   * @param date - Date to check
   * @returns True if the date is excluded
   */
  private isExcluded;
  private isExcludedEpoch;
  /** Sorted, de-duplicated, and EXDATE-filtered explicit recurrence dates. */
  private getNumericRDates;
  private numericRDateLowerBound;
  /**
   * Excludes exDate entries from the given array of dates.
   * @param dates - Array of dates to filter
   * @returns Filtered array with exDate entries removed
   */
  private excludeExDates;
  /**
   * Finalizes the recurrence set in RFC 5545 order: bound the RRULE-generated
   * dates by COUNT, union RDATE, then subtract EXDATE.
   * @param dates - Array of dates generated by the rule
   * @param iterator - Optional iterator function
   * @returns Final recurrence set
   */
  private applyCountLimitAndMergeRDates;
  /**
   * Streams the final recurrence set without materializing the complete RRULE.
   * A rule-only instance keeps COUNT/UNTIL scoped to RRULE generation while
   * sorted RDATE values are merged and EXDATE values are filtered at emission.
   */
  private iterateRecurrenceSet;
  private applyIterator;
  /** Stops RRULE generation once COUNT rule occurrences have been found. */
  private shouldBreakForCountLimit;
  private hasTimeOfDayBetween;
  private assertNumericCandidateReachable;
  private numericExhaustionCandidate;
  private tryNumericNext;
  private tryNumericPrevious;
  private tryNumericBetween;
  /**
   * Periods a plan may scan while the general engine it replaces stays within
   * maxIterations and maxCandidateEvaluations. previous() backs its search off
   * in powers of four, so its engine can visit four times the periods scanned.
   */
  private periodScanBudget;
  /** Resolve a period's wall times, or null when any needs the general engine (e.g. a DST gap). */
  private resolvePeriodEpochs;
  private isExcludedEpochMilliseconds;
  /**
   * First RRULE instant at or after `lowerMs` that EXDATE does not remove. An
   * instant after `stopAfterMs` is returned unchecked: a caller holding an
   * earlier RDATE needs no later rule instant. Returns null when UNTIL ends the
   * rule first, and undefined when the general engine must answer.
   */
  private periodScanForward;
  /**
   * Last RRULE instant at or before `upperMs` (and UNTIL) that EXDATE does not
   * remove. An instant before `stopBeforeMs` is returned unchecked: a caller
   * holding a later RDATE needs no earlier rule instant. Returns null before
   * DTSTART, and undefined when the general engine must answer.
   */
  private periodScanBackward;
  /** RRULE instants in [lowerMs, upperMs] without EXDATEs, or null when the general engine must answer. */
  private periodEpochsBetween;
  private tryPeriodNext;
  private tryPeriodPrevious;
  private tryPeriodBetween;
  /**
   * Returns all occurrences of the rule within a specified time window.
   * @param after - The start date or Temporal.ZonedDateTime object.
   * @param before - The end date or Temporal.ZonedDateTime object.
   * @param inc - Optional boolean flag to include the start and end dates in the results.
   * @returns An array of Temporal.ZonedDateTime objects representing all occurrences of the rule within the specified time window.
   */
  between(after: DateFilter, before: DateFilter, inc?: boolean): TOutput[];
  /**
   * Compute a rule-phase-aligned DTSTART at or just before the given window
   * start, jumping forward from the original DTSTART in whole multiples of
   * INTERVAL. Lets window queries skip iterating occurrences before the
   * window without disturbing cadence. Not valid for COUNT-limited rules,
   * where the occurrence set depends on the index from the true DTSTART.
   */
  private jumpAlignedDtstart;
  /**
   * Convenience helper: true if the exact instant is an occurrence of the rule.
   * This checks full date-time equality (including time and time zone).
   */
  matches(date: DateFilter): boolean;
  /**
   * Convenience helper: true if any occurrence falls on the given calendar day
   * in the rule's time zone. This ignores time-of-day granularity.
   */
  occursOn(date: TemporalPlainDateInput): boolean;
  private nextInternal;
  /**
   * Returns the next occurrence of the rule after a specified date.
   * @param after - The start date or Temporal.ZonedDateTime object.
   * @param inc - Optional boolean flag to include occurrences on the start date.
   * @returns The next occurrence of the rule after the specified date or null if no occurrences are found.
   */
  next(after?: DateFilter, inc?: boolean): TOutput | null;
  /**
   * Share traversal-anchor semantics across all query methods. Only the real
   * DTSTART can be forced into the occurrence set by includeDtstart.
   */
  private alignedQueryStart;
  private ruleFromAlignedDtstart;
  /**
   * Returns the previous occurrence of the rule before a specified date.
   * @param before - The end date or Temporal.ZonedDateTime object.
   * @param inc - Optional boolean flag to include occurrences on the end date.
   * @returns The previous occurrence of the rule before the specified date or null if no occurrences are found.
   */
  previous(before?: DateFilter, inc?: boolean): TOutput | null;
  /**
   * The latest occurrence of the RRULE itself at or before the target, with explicit RDATEs
   * held out of the scan.
   *
   * They have to be held out. The scan does not start from DTSTART: it starts from a
   * phase-aligned dtstart near the target and walks forward, so the occurrences between the
   * real DTSTART and that anchor are never generated. An RDATE is an absolute instant rather
   * than a phase, so iterateRecurrenceSet() flushes any that predate the anchor into the same
   * pass, and this scan keeps the last date it is handed. That leaves the last flushed RDATE
   * standing in for a rule occurrence the aligned scan never produced -- and because the scan
   * then has a non-null answer, the backoff loop below returns it instead of widening the
   * window to look for the real one. previous() merges the RDATEs back in afterwards.
   */
  private previousFromRule;
  /** A duration of `count` steps in this rule's frequency unit. */
  private freqDuration;
  toString(): string;
  private formatIcsDateTime;
  private joinDates;
  /**
   * Resolve the calendar dates selected within a month without expanding any
   * time BY-parts. This keeps the intermediate set bounded to calendar scale.
   */
  private generateMonthlyDateCandidates;
  private generateMonthlyOccurrences;
  /**
   * Resolve one recurrence year's matching calendar dates. BYHOUR,
   * BYMINUTE, BYSECOND, and BYSETPOS deliberately remain outside this helper;
   * callers consume the date x time product incrementally.
   */
  private generateYearlyDateCandidates;
  private addByDayDates;
  /**
   * Helper to find the next valid value from a sorted array
   */
  private findNextValidValue;
  /**
   * Efficiently find the next valid date for MINUTELY and SECONDLY frequency by jumping over
   * large gaps when BYXXX constraints don't match.
   */
  private findNextValidDate;
  private applyBySetPos;
  private isoWeekByDay;
  /**
   * Generate occurrences for a specific week number in a given year
   */
  private generateDateCandidatesForWeekInYear;
  private getRscaleCalendarId;
  private assertRscaleCalendarSupported;
  private pad2;
  private monthMatchesToken;
  private monthsOfYear;
  private rscaleMonth;
  private startOfYear;
  private endOfYear;
  private rscaleFirstWeekStart;
  private rscaleLastWeekCount;
  private lastDayOfMonth;
  /** Convert an ambient ZonedDateTime into polyfill space for RSCALE math. */
  private toRscaleZdt;
  private rscaleDate;
  private rscaleDateAfterUntil;
  private rscaleMatchesByYearDay;
  private rscaleMatchesByWeekNo;
  private rscaleMatchesByMonth;
  private rscaleMatchesByMonthDay;
  private rscaleMatchesByDayBasic;
  private rscaleDateMatches;
  private applySkipForDay;
  private generateMonthlyOccurrencesRscale;
  private _allRscaleNonGregorian;
}
//#endregion
export { DateFilter, Freq, RRuleOptions, RRuleResolvedOptions, RRuleTemporal, RRuleTemporalIterator, TemporalImplementation, TemporalPlainDate, TemporalPlainDateInput, TemporalZonedDateTime, TemporalZonedDateTimeInput, Weekday, allowedFreq, allowedWeekdays, weekdayToIsoDay };