import type { PersistedCodec } from "./use_persisted_state"; /** * WHERE A READER IS IN A RUN — the order its steps stand in, which one is open, * and how long they have been at it. * * Its own module because none of the three is layout. The ORDER is the shape's * whole claim: a run drawn in whatever order the read answered with is not a * sequence, and the sort has to be stable or two steps sharing a position swap * under the reader between renders. "Where they left off" has to hold for a run * with nothing to capture, a run already finished, and a stored position * pointing past a step that has since gone. And the clock is arithmetic a test * can state a `now` for, which a component reading one cannot. */ /** A reader's place in one run, as it survives a reload. */ export interface RunPlace { /** The step they navigated to; `null` where they have not moved and the run * places itself on the first thing still unanswered. */ at: number | null; /** When this reader STARTED the run, epoch ms — the clock the run counts up * from. Stamped once, so closing the tab does not restart it. */ started: number; } /** * What comes back out of storage, validated. A stored place is whatever some * earlier version of the page wrote, in some browser, possibly by hand — so a * number that is not one, or a shape that is not this, falls back rather than * resuming the run at `NaN`. */ export declare const runPlaceCodec: PersistedCodec; /** * THE STEPS IN THE ORDER THE WORK IS DONE — the sequence slot's own order, the * rows' own where the run binds none. * * Stable, and a step the sequence does not place goes LAST rather than first: a * row whose position nobody stated is not step zero, and sorting it there puts * an unplaced step in front of the one the run opens on. */ export declare function orderedSteps(rows: readonly T[], order: ((row: T) => number | null | undefined) | undefined): T[]; /** * THE STEP THE RUN IS ON. A run the reader has not moved in opens on the first * step still unanswered; one where everything is answered opens at its END, * which is the position past the last step where the run's own result stands. * * A STORED POSITION IS CLAMPED, never trusted: the steps are a read, so a place * remembered against seven of them is asked about four the week the run is * shortened, and an index past the end draws a panel over no step at all. */ export declare function atStep(stored: number | null, answered: readonly boolean[]): number; /** How long the reader has been in the run, in the two parts a pack words. */ export declare function elapsedSince(started: number, now: number): { hours: number; minutes: number; };