import { a as JsonLdOpeningHours } from "../../json-ld-D0yClzSm.js"; //#region src/core/dates/hours.d.ts /** * One weekday's hours, as an editor wrote them. `day` is an English weekday * name or its first three letters, in any case (`"Monday"`, `"mon"`), or a * number from 0 for Sunday to 6 for Saturday, like `Date#getDay`. */ interface OpeningHoursRow { day: string | number; hours: string; } /** A day's opening, in minutes after local midnight: 7 AM to 7 PM is `{ open: 420, close: 1140 }`. */ interface OpeningRange { open: number; /** Up to 1440, for a shop that closes at midnight. */ close: number; } /** * One row's hours text as minutes after local midnight, `"closed"`, or `null` * when it can't be read. * * It reads a range split on an em dash, an en dash, a hyphen, or "to", with * each end in any of these spellings, with or without periods in the AM or PM: * `7a`, `7 AM`, `7:30 PM`, `19:30`, `noon`, and `midnight`. "Closed" in any * case is `"closed"`. * * An overnight range such as `8p—2a` is `null`, as is one that closes before * it opens. So is anything else, such as "By appointment". What `null` means is * the caller's decision: {@link openingState} reports it as `unknown`, and the * pickup functions take a `whenUnknown` policy. */ declare function parseOpeningHours(text: string): OpeningRange | "closed" | null; /** * A row's `day` as a weekday number, from 0 for Sunday to 6 for Saturday, like * `Date#getDay` and `weekdayOf`, or `null` when it names no weekday. * * It's the matcher every opening-hours function uses to find a weekday's row, * so code that words its own hours summary reads the rows the same way * {@link openingState} does. It reads a full English weekday name or its first * three letters, in any case and with surrounding spaces trimmed (`"Monday"`, * `"mon"`, `" MON "`), or an integer from 0 to 6. Anything else is `null`, * including another prefix such as `"Mo"` or `"Tues"`, a misspelling, and a * number out of range. * * ```ts * parseWeekday("Saturday"); // 6 * parseWeekday("sun"); // 0 * parseWeekday("Tues"); // null * ``` */ declare function parseWeekday(day: string | number): number | null; /** Where a shop stands at one instant, from {@link openingState}. */ type OpeningState = /** Open now, until `closesAt`. */ { kind: "open"; closesAt: Date; } | /** Closed now. `opensAt` is the next opening in the coming week, or null when the rows name none. */ { kind: "closed"; opensAt: Date | null; } | /** Today's row is missing or can't be read. */ { kind: "unknown"; }; /** Options for {@link openingState}. */ interface OpeningStateOptions { /** The shop's IANA time zone, for example, `"America/Chicago"`. A site fact, so no default. */ timeZone: string; /** The instant to answer for. Defaults to the current time. */ now?: Date | number; } /** * Whether the shop is open at `now`, on its own clock. * * `open` carries the closing instant. `closed` carries the next opening within * the coming week, skipping any day whose row is missing or can't be read, or * `null` when there's none. `unknown` means today's row is missing or can't * be read, so the rows can't say. * * Both instants come from `zonedTimeToUtc`, so they're right on a daylight * saving change day. */ declare function openingState(rows: readonly OpeningHoursRow[], options: OpeningStateOptions): OpeningState; /** Options for {@link pickupSlots} and {@link pickupProblem}. Every one is the shop's policy. */ interface PickupOptions { /** The shop's IANA time zone, for example, `"America/Chicago"`. */ timeZone: string; /** How long an order takes to make, in minutes. The ASAP slot is ready this long from now. */ prepMinutes: number; /** The earliest timed slot is at least this many minutes out, or `prepMinutes` if that's longer. */ minLeadMinutes: number; /** Minutes between timed slots, aligned to the shop's clock: 15 gives :00, :15, :30, :45. */ stepMinutes: number; /** How far ahead a pickup can be, in minutes from now. */ horizonMinutes: number; /** The most timed slots to list, after the ASAP slot. */ maxSlots: number; /** Minutes past closing that {@link pickupProblem} still accepts, for a slot chosen at the edge. */ closeGraceMinutes: number; /** BCP 47 locale for a timed slot's label, for example, `"en-US"`. */ locale: string; /** * What today's hours mean when its row is missing or can't be read. * `"open"` fails open, so a typo in the hours can't stop every sale, with no * closing time to bound the slots. `"closed"` offers and accepts nothing. */ whenUnknown: "open" | "closed"; /** The instant to answer for. Defaults to the current time. */ now?: Date | number; } /** A pickup time to offer, from {@link pickupSlots}. */ type PickupSlot = /** As soon as the order is made: `prepMinutes` from now. The site words its label. */ { kind: "asap"; readyAt: Date; } | /** A set time, with its label in `locale` on the shop's clock, such as "6:45 PM". */ { kind: "timed"; readyAt: Date; label: string; }; /** * The pickup times to offer now: an ASAP slot, then up to `maxSlots` timed * slots on the shop's clock. * * Timed slots start `minLeadMinutes` out (or `prepMinutes`, if longer), * rounded up to the next `stepMinutes` mark on the shop's wall clock, and stop * at closing time or `horizonMinutes` from now, whichever comes first. A slot * exactly at closing time is offered. * * The list is empty when the shop is closed, when an order started now can't * be ready before closing, or when today's hours can't be read and * `whenUnknown` is `"closed"`. The slots don't reach into tomorrow: a shop * closed now takes no pickups. */ declare function pickupSlots(rows: readonly OpeningHoursRow[], options: PickupOptions): PickupSlot[]; /** * Why the server should refuse a pickup at `readyAt`, or `null` to accept it: * * - `"closed"`: the shop is closed now, or today's hours can't be read and * `whenUnknown` is `"closed"`. {@link pickupSlots} offers nothing then, so * the server accepts nothing. * - `"after-close"`: `readyAt` is more than `closeGraceMinutes` past today's * closing time. * - `"too-far"`: `readyAt` is more than `horizonMinutes` from now. * * A code rather than a message, so a site words it and a native client can * localize it. */ declare function pickupProblem(rows: readonly OpeningHoursRow[], readyAt: Date | number, options: PickupOptions): "closed" | "after-close" | "too-far" | null; /** * The rows as structured-data opening hours, for `localBusinessJsonLd` in * `louise-toolkit/seo`: days with the same hours share one entry, Monday first. * A closed day, or one whose row can't be read, is left out. A midnight close * is `"23:59"`, the form search engines read. * * It parses with {@link parseOpeningHours}, so the hours a page shows and the * hours in its structured data can't disagree. */ declare function openingHoursJsonLd(rows: readonly OpeningHoursRow[]): JsonLdOpeningHours[]; //#endregion //#region src/core/dates/index.d.ts /** A calendar day as `YYYY-MM-DD`. A plain string, documented by name. */ type IsoDate = string; /** True when `value` is a real calendar day in `YYYY-MM-DD` form. */ declare function isIsoDate(value: unknown): value is IsoDate; /** * The calendar day an instant falls on in `timeZone`, as `YYYY-MM-DD`. * The `en-CA` locale is the one whose numeric short date IS ISO order. */ declare function isoDateIn(when: Date | number, timeZone: string): IsoDate; /** Today in `timeZone`, as `YYYY-MM-DD`. `now` is injectable for tests. */ declare function todayIn(timeZone: string, now?: Date | number): IsoDate; /** `iso` plus `days` (negative to go back). Crosses months, years and leap days; * never consults a zone, so DST cannot make a day 23 or 25 hours long here. */ declare function addDays(iso: IsoDate, days: number): IsoDate; /** Whole days from `from` to `to`—positive when `to` is later. */ declare function daysBetween(from: IsoDate, to: IsoDate): number; /** Day of the week of a calendar day: 0 = Sunday … 6 = Saturday, like `Date#getDay`. */ declare function weekdayOf(iso: IsoDate): number; /** * The instant at which the wall clock in `timeZone` reads `time` on `iso`—"9 AM * Tulsa time next Tuesday" as a `Date`, for a scheduled pickup or a * booking slot. `time` is `HH:MM` (24-hour). * * The two DST edge cases resolve the way `Temporal`'s "compatible" mode does: * * - a time that does not exist (2:30 AM on the spring-forward day) moves * forward by the gap—3:30 AM; * - a time that happens twice (1:30 AM on the fall-back day) is the FIRST * occurrence, the one still on daylight time. */ declare function zonedTimeToUtc(iso: IsoDate, time: string, timeZone: string): Date; interface FormatDateOptions extends Omit { /** BCP 47 locale. Default `"en-US"`. */ locale?: string; } /** * An instant as the customer lived it, in `timeZone`—"July 4, 2026" by * default; pass `Intl.DateTimeFormat` fields to change that. Empty string for * `null`/`undefined`/an unparseable value, so a template can render it blind. */ declare function formatInstant(when: Date | number | string | null | undefined, timeZone: string, options?: FormatDateOptions): string; /** * A stored calendar day spelled out—"July 1, 2026" by default. Takes no zone: * it IS a day, not a moment, so it is read at UTC noon and formatted in UTC and * nothing can move it. Empty string for `null`/`undefined`; anything that is * not a calendar date is returned as it came. */ declare function formatCalendarDate(iso: IsoDate | null | undefined, options?: FormatDateOptions): string; //#endregion export { FormatDateOptions, IsoDate, type OpeningHoursRow, type OpeningRange, type OpeningState, type OpeningStateOptions, type PickupOptions, type PickupSlot, addDays, daysBetween, formatCalendarDate, formatInstant, isIsoDate, isoDateIn, openingHoursJsonLd, openingState, parseOpeningHours, parseWeekday, pickupProblem, pickupSlots, todayIn, weekdayOf, zonedTimeToUtc };