/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ import type { PagedLoading } from "../shared/loading.js"; import { type CalendarRow, type CalendarValue } from "./model.js"; /** The paged resource kind, as the payload carries it. */ export type CalendarPagedValue = Extract["value"]; /** How many of the paged kind's resources a window holds, as the Plan's paged windows hold. */ export declare const CALENDAR_PAGE_SIZE = 200; /** * The paged kind's places a view shows, as it reports them: the first and the * last, in the kind's order, and the result they belong to — a new narrowing * is a new result, whose places start again. */ export interface CalendarPagedView { /** The first place shown. */ readonly first: number; /** The last place shown. */ readonly last: number; /** The result the places are of ({@link CalendarPages.result}). */ readonly result: number; } /** Where the views report the paged kind's places they show, and the reader hears them: a store of one view. */ export interface CalendarPagedDemand { /** The view last reported; `undefined` before one is. */ readonly get: () => CalendarPagedView | undefined; /** Reports the places shown: a view the store holds already moves nothing. */ readonly set: (view: CalendarPagedView) => void; /** Hears each move; returns the unsubscribe. */ readonly subscribe: (listener: () => void) => () => void; } /** * A store of the paged kind's places in view. * * @returns The store, holding none */ export declare function createPagedDemand(): CalendarPagedDemand; /** What the frame shows of the paged kind: the windows it holds, by window, and what is known of the rest. */ export interface CalendarPages { /** The kind's slot. */ readonly kind: string; /** Its name: the group its rows draw under. */ readonly group: string; /** How many resources it has — its narrowing holds, when its source narrows it — once known. */ readonly total: number | undefined; /** Each window held, its resources' rows in the order they draw, by window. */ readonly windows: ReadonlyMap; /** Each window whose read failed, by window: why. */ readonly failed: ReadonlyMap; /** * Why the kind's own reads — its count, its revision, its narrowing — threw: the source's failure, as the Plan's and * the Sheet's drivers take one; `undefined` while none did. It ends the cold load and is said on the footer's line, * with Retry; the windows a source that cannot say its snapshot fails are said where their places would be. */ readonly sourceError: string | undefined; /** Whether a window the view shows is read: the footer's line says so, and main is busy. */ readonly reading: boolean; /** Whether what it holds stands in for a read again — a new snapshot's, a new narrowing's — retained until it lands. */ readonly stale: boolean; /** The narrowing its windows serve, as the source names it; `undefined` where no source narrows the kind. */ readonly narrowing: string | undefined; /** Which result its places are of: a new narrowing is a new one, whose places start again. */ readonly result: number; /** Whether a window has landed, or a read of the kind failed: before then, the frame's cold load covers it. */ readonly ready: boolean; /** * What the footer's loading line says of it (#1398, CL3): a window the view shows that could not be read, the * places it holds; else the kind's own reads that failed, with no places; a new narrowing's windows read while the * last view stands in; a window the view shows in flight, the places it holds; `undefined` while none is. */ readonly line: PagedLoading | undefined; /** Asks every failed window again. */ readonly retry: () => void; } /** * The resource at a place, once its window is held. * * @param pages - What the frame holds of the paged kind * @param at - The place, in the kind's order * @returns Its row; `undefined` while its window is not held */ export declare function pagedRowAt(pages: CalendarPages, at: number): CalendarRow | undefined; /** * Why a place's window could not be read, while its read has failed. * * @param pages - What the frame holds of the paged kind * @param at - The place * @returns Why; `undefined` for a window not failed */ export declare function pagedFailureAt(pages: CalendarPages, at: number): string | undefined; /** * How many places the views lay the paged kind out in: its count, once known; * before then, the places of the windows in from the first on — each held * window's rows, and a window whose read failed a whole window, as the Plan's * failed window spans one before the count is known (`failedSpan`), so its * failure is said where its places would be. * * @param pages - What the frame holds of the paged kind * @returns The places */ export declare function pagedPlaces(pages: CalendarPages): number; /** * A stretch of the paged kind's places, as the views lay them out (#1424): a * window held, its rows from its first place on; a window whose read failed, * its places; or places not read yet, one run however many. */ export type CalendarPagedSegment = { readonly kind: "held"; readonly from: number; readonly rows: readonly CalendarRow[]; } | { readonly kind: "failed"; readonly from: number; readonly to: number; } | { readonly kind: "unread"; readonly from: number; readonly to: number; }; /** * The paged kind's places in their order as stretches (see * {@link CalendarPagedSegment}): each window the frame holds or whose read * failed, and one run for each stretch of places between them not read yet — * as many stretches as the windows held, however many places the kind has, * never one a place. * * @param pages - The windows the frame holds of the paged kind, and those whose read failed * @param places - How many places it lays out ({@link pagedPlaces}) * @returns The stretches, in the kind's order, covering every place once */ export declare function pagedSegments(pages: Pick, places: number): CalendarPagedSegment[]; /** * The windows a view shows: those its places fall in — of the result it reads * now; a view of another result's places, or none reported yet, shows the * first window. * * @param view - The view last reported * @param result - The result read now * @returns The windows, ascending */ export declare function shownWindows(view: CalendarPagedView | undefined, result: number): number[]; /** * The windows the reader reads: those the view shows and one either side, so a * scroll on finds the next one read — within the kind's count, once known. * * @param view - The view last reported * @param result - The result read now * @param total - How many resources the kind has, once known * @returns The windows, ascending */ export declare function wantedWindows(view: CalendarPagedView | undefined, result: number, total: number | undefined): number[]; /** * The paged kind's windows around the view, read in a component of its own * (see the module docs), handed to the frame only as what it holds moves. * * @param props - The paged kind, as the payload carries it; its name and icon, as its rows draw them; where the views * report the places they show; and where the windows go * @returns Nothing: it reads */ export declare function CalendarPagesReader({ paged, name, icon, demand, onPages }: { paged: CalendarPagedValue; name: string; icon: string; demand: CalendarPagedDemand; onPages: (pages: CalendarPages) => void; }): null; //# sourceMappingURL=pages.d.ts.map