/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * The Roster's model over the app's own records (#1369, `Builder Interfaces * Spec.md` §5, §9): the payload as the renderer reads it; the Roster's pure * functions and codecs compiled once per duty row type, as the Allocation's * domain is — East decides which types are the same; the week assembled from * the duties' rows, the targets' and the week's own row, drafts in place; the * app's pay asked a person at a time; and the views' helpers. No UI, and no * record writes. * * @packageDocumentation */ import { SortedMap, type EastType, type EastTypeValue, type ValueTypeOf, type option } from "@elaraai/east"; import type { ColorTokenType } from "@elaraai/east-ui"; import { RosterAssignmentTypeFor, RosterContextType, RosterCoverageType, RosterIssueType, RosterPayType, RosterPayloadType, RosterPlaceType, RosterRequirementType, RosterSlotType, RosterStatusType, RosterTargetRolesType, RosterWeekTypeFor, RosterWhoType, ScheduleRosterRolesType } from "@elaraai/e3-ui/internal"; import type { Formatters } from "@elaraai/east-ui-components"; export { DAY, NARROW_WIDTH, dayStart, weekStart } from "../shared/schedule/window.js"; /** The decoded payload. */ export type RosterPayload = ValueTypeOf; /** * The payload as the renderer reads it: with which people and activities the * slice shows (#1342) — `none` for every one — beside every person and * activity, which coverage, pay and checks read. */ export type RosterValue = RosterPayload & { visiblePeople: option>; visibleActivities: option>; }; /** A duty as the Roster reads it, its row the app's — opaque here, read through the app's own functions. */ export type Assignment = ValueTypeOf>; /** A week as the Roster reads it. */ export type Week = ValueTypeOf>; export type Slot = ValueTypeOf; /** Where a duty stands: its day, its shift, and its group or none (#1548). */ export type Place = ValueTypeOf; export type Requirement = ValueTypeOf; export type Context = ValueTypeOf; export type Coverage = ValueTypeOf; export type Issue = ValueTypeOf; export type Status = ValueTypeOf; export type Who = ValueTypeOf; /** A duty's roles, as the duty kind reads them from its row. */ export type Roles = ValueTypeOf; /** A target's roles, as the targets read them from their row. */ export type TargetRoles = ValueTypeOf; /** Each duty's cost by the app's pay codes, by its key. */ export type Pay = ValueTypeOf; export type Person = RosterValue["people"][number]; export type Activity = RosterValue["activities"][number]; export type Shift = RosterValue["shifts"][number]; export type Proposal = RosterValue["proposals"][number]; /** A week pattern, as the app declares it (#1406): seven days from the week's first day, each a shift's key or none. */ export type Pattern = RosterValue["patterns"][number]; /** A suggestion the week can take: in its slot of the week. */ export type PlacedProposal = Proposal & { readonly slot: Slot; }; export type RosterStyles = Record>; /** The Roster's layouts. */ export type RosterLayout = RosterPayload["settings"]["layout"]["type"]; /** The Roster's periods: Shifts shows a day or a week, People a week or a month (#1406). */ export type RosterPeriod = RosterPayload["settings"]["period"]["type"]; /** * Persisted viewer preferences; dates are epochs for local storage. `period` is the period of the layout in view, and * `held` the period the other layout had, so each layout keeps its own (#1406, P1); a view kept before `held` reads as * the defaults. */ export interface RosterView { layout: RosterLayout; period: RosterPeriod; date: number; held?: Partial> | undefined; } /** * The inspector's selection is separate from edits and library filtering. A `personWeek` is a person's week (#1406, * D11): the inspector's person Details read that week, and a pattern applies to it. A `shiftDay` is a shift's day * across the groups (#1568): a day of a work requirement lane where the People layout draws no bands, whose Details * draw each group's slot and the skill lines summed over them. A work requirement's day names its week (`start`), as a * person-week does: a month's mark is a day of one of its weeks, which the inspector then reads. */ export type Selection = { type: "assignment" | "proposal" | "person"; key: string; } | { type: "slot" | "requirement"; slot: Slot; start?: number; } | { type: "group"; key: string; } | { type: "shift"; key: string; } | { type: "personWeek"; key: string; start: number; } | { type: "shiftDay"; shift: string; day: number; start?: number; }; /** * The week a selection names (#1406, D11; #1568): a person-week's, or a work requirement's day's — the week the * inspector, the commands and the checks then work over where a month shows several. * * @param selection - The selection * @returns Its week's first day, as a time; `undefined` for a selection naming none */ export declare function selectionWeek(selection: Selection | undefined): number | undefined; /** * A period a layout takes (#1406, D1): the one given where the layout takes it, else the layout's first — Shifts a * day, People a week. * * @param layout - The layout * @param period - The period asked for * @param offered - The periods this Roster offers (`viewPeriods`): a layout taking none of them keeps its own * @returns The period the layout shows */ export declare function periodOf(layout: RosterLayout, period: RosterPeriod | undefined, offered?: readonly { readonly type: string; }[]): RosterPeriod; /** * Where pressing an issue goes, as its title's click takes it. In Week and Day, its day, with what it names selected. In * Month, which draws no one duty, its week in Week (P24) — or, with Week not offered, the month stays and the person-week * of the duty's person is selected: moving the date to a day of a week that starts in the month before would move the month. * * @param issue - The issue * @param view - The view * @param start - The first day of the issue's week * @param week - The issue's week as drafted * @param opensWeek - Whether the layout in view offers Week * @returns The view to show and what to select; each `undefined` where it stays as it is */ export declare function issueGoesTo(issue: Issue, view: RosterView, start: Date, week: Week, opensWeek: boolean): { view: RosterView | undefined; select: Selection | undefined; }; /** * The weeks in view, and the window the Roster reads them over (#1406, D2): one week — the Shifts layout's day is a * day of it — or a month's, the four to six weeks that touch the month from the configured week start. */ export interface RosterSpan { /** The period in view. */ readonly period: RosterPeriod; /** The first week's first day. */ readonly start: Date; /** Each week's first day, in order: one, or a month's four to six. */ readonly weeks: readonly Date[]; /** The span's first instant: its first week's first day. */ readonly from: Date; /** The span's end, exclusive: the day after its last week's last. */ readonly to: Date; /** The month in view, its first day; `undefined` for a week. */ readonly month: Date | undefined; } /** The first day of a UTC date's month. */ export declare function monthStart(date: Date): Date; /** * The span a view shows (see {@link RosterSpan}). * * @param date - The view's date, an epoch * @param period - The period in view * @param sunday - Whether weeks start on Sunday * @returns The span */ export declare function rosterSpan(date: number, period: RosterPeriod, sunday: boolean): RosterSpan; /** * The ISO week number of a week, by its fourth day — the week's Thursday where weeks start on Monday, its Wednesday * where they start on Sunday: the number the shared navigator prints. * * @param week - The week's first day * @returns Its number */ export declare function weekNumber(week: Date): number; /** * A span's words (#1406, P2, P28): a week's days — `12–18 Mar` — or a month's weeks — `W10–W14`. * * @param format - The app's formatters * @param span - The span * @returns Its words */ export declare function spanWords(format: Pick, span: RosterSpan): string; /** * A month's label (#1406, P2): `March 2028 · W10–W14 · Mar 5 – Apr 1`. * * @param format - The app's formatters * @param span - The month's span * @returns The label */ export declare function monthWords(format: Pick, span: RosterSpan): string; /** * One week of a span, as the frame assembles it from the records' rows, drafts in place (#1406): what the month's * cells draw, and what a pattern dropped on it applies to. */ export interface WeekState { /** Its first day. */ readonly start: Date; /** The week as drafted, and as the records hold it. */ readonly week: Week; readonly held: Week; /** Its duties as drafted, and as stored: each placed duty's row. */ readonly duties: PlacedDuties; readonly heldDuties: PlacedDuties; /** Its targets as drafted. */ readonly targets: PlacedTargets; /** Its periods (#1550): its own, or each of its seven days' where the Roster publishes by the day. */ readonly periods: readonly WeekPeriod[]; } export declare const sameSlot: (x: { readonly day: bigint; readonly group: string; readonly shift: string; }, y: { readonly day: bigint; readonly group: string; readonly shift: string; }) => boolean; export declare const slotKey: (value: { readonly day: bigint; readonly group: string; readonly shift: string; }, ctx?: { refs: Map; currentPath: string[]; }) => string; export declare const parseSlot: (x: string) => { success: true; value: { readonly day: bigint; readonly group: string; readonly shift: string; }; position: number; } | { success: false; error: string; position: number; }; export declare const weekKey: (value: Date, ctx?: { refs: Map; currentPath: string[]; }) => string; export declare const compareDate: (x: Date, y: Date) => 1 | 0 | -1; export declare const compareString: (x: string, y: string) => 1 | 0 | -1; export declare const compareSlot: (x: { readonly day: bigint; readonly group: string; readonly shift: string; }, y: { readonly day: bigint; readonly group: string; readonly shift: string; }) => 1 | 0 | -1; export declare const samePlace: (a: Place, b: Place) => boolean; /** Whether two groups are the same: one group's both, or both no group (#1548). */ export declare const sameGroup: (a: option, b: option) => boolean; export declare const placeKey: (place: Place) => string; /** A place read back from its key (`placeKey`): what a drop's slot names; `undefined` for text naming none. */ export declare function parsePlace(text: string): Place | undefined; /** A group's slot as a place: the place its duties stand in. */ export declare function placeOf(slot: Slot): Place; /** The slot a place is, a group's; `undefined` for no group's (#1548). */ export declare function slotOfPlace(place: Place): Slot | undefined; /** Whether a duty stands in a slot: its group's shift on its day. */ export declare function inSlot(a: Pick, slot: Slot): boolean; /** The group a duty stands in, by its key; `undefined` for a duty in no group yet (#1548). */ export declare function groupOf(a: Pick): string | undefined; /** * No group's band (#1548): the key the No group band of either layout is drawn and folded by — the empty key, as the * Calendar's Unassigned row is keyed. Where a duty may be in no group, no group of the Roster's takes it ({@link configError}). */ export declare const NO_GROUP = ""; /** * A group's name where the Roster says where a duty stands: the group's label — its key, for a group no longer * configured — or the vocabulary's No group, for none (#1548). * * @param value - The payload: its groups and its words * @param group - The group, or none * @returns Its name */ export declare function groupName(value: Pick, group: option): string; export declare const sameWho: (a: Who, b: Who) => boolean; export declare const whoKey: (who: Who) => string; /** * The window the Roster reads a week's duties over: the week, and the twelve * hours either side a duty's start may stand from its shift's start on one of * the week's days (§5.5, rule 1). * * @param start - The week's first day * @returns The window, half open */ export declare function weekWindow(start: Date): { from: Date; to: Date; }; /** * The window the Roster reads a span's duties over (#1406, P26): the span's weeks, and the twelve hours either side a * duty's start may stand from its shift's start on one of their days. * * @param span - The span * @returns The window, half open */ export declare function spanWindow(span: Pick): { from: Date; to: Date; }; /** * The week itself: its seven days. * * @param start - The week's first day * @returns The week, half open */ export declare function weekSpan(start: Date): { from: Date; to: Date; }; /** * The week before a week. * * @param start - The week's first day * @returns The week before's first day */ export declare function weekBefore(start: Date): Date; /** * A duty's times moved to start elsewhere, its length kept: what a later start's fix writes. * * @param a - The duty * @param at - Where it starts now * @returns Its start and end */ export declare function startingAt(a: Pick, at: Date): { start: Date; end: Date; }; /** A duty kind's placement of one duty: placed in the week, another week's, or a duty the Roster cannot place. */ export type Placement = { type: "placed"; value: Assignment; } | { type: "elsewhere"; value: null; } | { type: "unplaced"; value: Issue; }; /** The Roster's codecs and pure functions at one duty row type, compiled once. */ export interface RosterDomain { /** The app's duty row type. */ readonly rowType: EastType; /** A row as bytes, and back. */ readonly encodeRow: (row: unknown) => Uint8Array; readonly decodeRow: (bytes: Uint8Array) => unknown; /** Whether two duties read alike: a duty unlike the record's is a draft. */ readonly sameAssignment: (a: Assignment, b: Assignment) => boolean; /** Whether two weeks read alike: what the fit asks again over. */ readonly sameWeek: (a: Week, b: Week) => boolean; /** A duty as the Roster reads it, in the week of `start`. */ readonly placement: (roles: Roles, row: unknown, key: string, start: Date, context: Context) => Placement; /** Every configured slot's coverage, its cost the pay's. */ readonly coverage: (week: Week, context: Context, pay: Pay) => SortedMap; /** The built-in checks. */ readonly check: (week: Week, context: Context) => Issue[]; /** Each person's hours for the week. */ readonly hours: (week: Week, context: Context) => SortedMap; /** The pay's question, as bytes. */ readonly encodePayRequest: (request: { who: Who; start: Date; duties: SortedMap; context: Context; }) => Uint8Array; /** One person's duties, as bytes: what a person's pay is kept by. */ readonly encodeDuties: (duties: SortedMap) => Uint8Array; /** The app's check's question, as bytes. */ readonly encodeCheckContext: (context: { start: Date; week: Week; context: Context; coverage: SortedMap; pay: Pay; }) => Uint8Array; } /** * The domain for a duty kind's row type: built and compiled the first time a * type is seen, then shared — East decides which types are the same. * * @param rowType - The duty kind's `rowType` * @returns Its codecs and compiled pure functions */ export declare function rosterDomain(rowType: EastTypeValue): RosterDomain; /** The app's check's question over a reference record (#1551): the week's, and the record's rows over it by key. */ export interface RosterReferenceCheckAsk { start: Date; week: Week; context: Context; coverage: SortedMap; pay: Pay; reference: SortedMap; } /** * The app's check's question at the duty row type and a reference record's * row type (#1551), `CheckContext(R, P)`, as bytes: its encoder made the first * time the pair is seen, then shared — East decides which types are the same. * * @param rowType - The duty kind's `rowType` * @param referenceType - The reference record's row type * @returns The question's encoder */ export declare function rosterReferenceCheckEncoder(rowType: EastTypeValue, referenceType: EastTypeValue): (ask: RosterReferenceCheckAsk) => Uint8Array; export declare function rosterTimes(): { dayOf: (start: Date, clock: Shift["start"]) => Date; shiftStart: (day: Date, shift: Shift) => Date; move: (roles: Roles, start: Date, place: Place, context: Context) => option; newDuty: (who: Who, place: Place, start: Date, position: option, activity: option, context: Context) => option; }; /** One stored duty as the duty kind's `rows` gives it: its roles, its row's bytes, and its row, decoded once. */ export interface StoredDuty { readonly roles: Roles; readonly bytes: Uint8Array; readonly row: unknown; } /** One stored target as the targets' `rows` give it: its roles and its row's bytes. */ export interface StoredTarget { readonly roles: TargetRoles; readonly bytes: Uint8Array; } /** A duty's row as a draft holds it: its bytes and roles, or `undefined` for one the draft removes. */ export interface DraftedDuty { readonly bytes: Uint8Array; readonly roles: Roles; readonly row: unknown; } /** The week's duties as one reading holds them: each placed duty, each one's row, and what the Roster cannot place. */ export interface PlacedDuties { /** Each duty placed in the week, by key. */ readonly assignments: SortedMap; /** Each placed duty's row's bytes and roles, by key: what a write starts from. */ readonly rows: ReadonlyMap; /** The issues listing the week's duties the Roster cannot place (§5.5, rule 8). */ readonly unplaced: readonly Issue[]; } /** * The week's duties as the records hold them: each stored duty read in the * week of `start`, by key. * * @param domain - The duty row type's domain * @param stored - The duties the window read * @param start - The week's first day * @param context - The configuration * @returns The duties placed in the week, their rows, and what cannot be placed */ export declare function placeStored(domain: RosterDomain, stored: ReadonlyMap, start: Date, context: Context): PlacedDuties; /** * The week's duties as drafted: the stored ones, each a draft holds in its * draft's place — a draft of any week, placed in this one where its day is — * and each one a draft removes gone. * * @param domain - The duty row type's domain * @param stored - The week's duties as the records hold them * @param drafts - Every drafted duty of the session, by key: its row, or `undefined` for one removed * @param start - The week's first day * @param context - The configuration * @returns The duties placed in the week as drafted, their rows, and what cannot be placed */ export declare function placeDrafted(domain: RosterDomain, stored: PlacedDuties, drafts: ReadonlyMap, start: Date, context: Context): PlacedDuties; /** The week's targets: each slot's requirement, and the key of the row that holds it. */ export interface PlacedTargets { readonly requirements: SortedMap; /** Each slot's target row: its key and its bytes, as drafted. */ readonly rows: SortedMap; } /** * The week's targets, a row per slot: the first row of a slot in key order * holds its target; a row of another day, group or shift than the Roster's is * no slot's. A slot's hours needed are the targets' own (#1678), read from its * row as drafted with its shift's nominal hours, so an edit of the row moves * them before Save. * * @param stored - The targets the week's read gave, by key * @param drafts - Every drafted target of the session, by key: its bytes and roles, or `undefined` for one removed * @param start - The week's first day * @param value - The payload: its groups, its shifts and its targets * @returns The week's requirements, and each slot's row; none for a Roster with no targets */ export declare function placeTargets(stored: ReadonlyMap, drafts: ReadonlyMap, start: Date, value: Pick): PlacedTargets; /** A period's own row — a week's, or a day's where the Roster publishes by the day (#1550) — as drafted, and what it says. */ export interface PlacedPeriod { /** Its row's bytes; `undefined` for a period with no row: Not started. */ readonly bytes: Uint8Array | undefined; /** Its status. */ readonly status: Status; /** The suggestions it dismissed. */ readonly dismissed: Set; } /** A period with no row of its own: Not started — its status the draft's, nothing dismissed. */ export declare const NO_PERIOD: PlacedPeriod; /** Whether a period's row is its own: what a period with no row reads as Not started for. */ export declare function started(period: PlacedPeriod): boolean; /** * One of a week's periods (#1550): the week itself, where the Roster publishes by the week, or one of its days, where * `Schedule.periods` declares `every: "day"` — what Publish writes, and what a gesture on one of its days asks first. */ export interface WeekPeriod { /** Its first instant: its row's key, the week's first day or the day's. */ readonly start: Date; /** The first of the week's days it holds, from zero. */ readonly from: number; /** The day after its last, from zero: seven for the week. */ readonly to: number; /** Its own row as drafted, and as stored. */ readonly period: PlacedPeriod; readonly held: PlacedPeriod; } /** Whether the Roster publishes by the day: its periods declare `every: "day"` (#1550). */ export declare function byDay(value: Pick): boolean; /** * A week's periods (#1550): the week, or each of its days. * * @param start - The week's first day * @param days - Whether the periods are days * @param row - A period's own row as drafted and as stored, by its first instant * @returns The periods, in the week's order */ export declare function weekPeriods(start: Date, days: boolean, row: (at: Date) => { readonly period: PlacedPeriod; readonly held: PlacedPeriod; }): readonly WeekPeriod[]; /** * The period holding a day of its week (#1550). * * @param periods - The week's periods * @param day - The day, from zero * @returns The period; `undefined` for a day the week does not hold */ export declare function periodOn(periods: readonly WeekPeriod[], day: bigint | number): WeekPeriod | undefined; /** Whether a period takes edits (#1550): its row a draft's — Not started among them — as stored and as drafted. */ export declare function takesEdits(period: WeekPeriod): boolean; /** * A week's status from its periods' (#1550), what the app's check and optimiser read: its own row's, or over its days * the draft's while any day is a draft, else — every day published — the published case at the latest time a day * was published, else the first of the app's own cases a day holds. * * @param periods - The week's periods' rows * @returns The status */ export declare function weekStatus(periods: readonly PlacedPeriod[]): Status; /** * A week as the Roster reads it: its duties, its targets and its periods' rows — its status theirs (`weekStatus`), * and its dismissals every period's. * * @param duties - Its duties * @param targets - Its targets * @param periods - Its periods' rows: its own, or its days' * @returns The week */ export declare function weekOf(duties: PlacedDuties, targets: PlacedTargets, periods: readonly PlacedPeriod[]): Week; /** A week with nothing in it yet: Not started. */ export declare function emptyWeek(): Week; /** Whether a period is open to edits by its status: a draft — Not started among them — and never the published case or another. */ export declare function editableStatus(status: Status): boolean; /** * A count of a roster's issues as it is said: `1 issue`, `3 issues`. * * @param n - How many issues * @returns The count in words */ export declare function issuesSaid(n: number): string; /** A period's status chip's words: Not started, Draft, Published, or the app's own case by its name. */ export declare function statusText(period: PlacedPeriod): string; /** * The status chip's words over a week's periods (#1550): its one period's (`statusText`), or over its days Published * once every day is, Not started while none is, the app's own case where every day holds it, else how many days are * published — `3 of 7 published` — or Draft while none is. * * @param periods - The week's periods' rows * @returns The words */ export declare function periodsText(periods: readonly PlacedPeriod[]): string; /** * Install (or clear) the probe the pay's questions are told to. Test use only. * * @param fn - Told of each question's person or agency; `undefined` clears it */ export declare function setRosterPayProbe(fn: ((who: Who) => void) | undefined): void; /** What the pay gives the week: each duty's cost by code, and whose pay could not be worked out. */ export interface WeekPay { /** Each duty's cost by the app's codes, by its key: every person's answers merged. */ readonly pay: Pay; /** Each person or agency whose pay threw, and why. */ readonly failed: readonly { readonly who: Who; readonly error: string; }[]; } /** No pay: no costs show. */ export declare const NO_PAY: WeekPay; /** * The app's pay, asked a person at a time (§5.6, B17): once for each person * with duties in the week and once for each agency with requests, each answer * kept by the bytes of that person's duties, so a change asks again only for * the people whose duties, or whose duties' rows, it changed. A new context or * week asks everyone again. */ export declare class RosterPayCache { private kept; private context; /** The week the answers kept are of, by its first day: another week, by East's ordering, asks everyone again (#1650). */ private start; /** * The week's pay. * * @param domain - The duty row type's domain * @param pay - The app's pay, over bytes * @param week - The week as drafted * @param start - Its first day * @param context - The configuration, kept by identity: a new one asks everyone again * @returns Each duty's cost, and whose pay threw */ run(domain: RosterDomain, pay: (bytes: Uint8Array) => Pay, week: Week, start: Date, context: Context): WeekPay; } /** * Each week of a month's coverage, as the People layout's work requirement * sums it (#1568): its hours alone, no pay asked, each week's kept by the week * as it was worked out over, so a change works out again only the weeks it * changed — an edit in one week leaves the others' standing. The week the * inspector reads is given its own coverage, whose hours its pay leaves as * they are. A new domain or context works out every week again. */ export declare class RosterSpanCoverage { /** Each week's coverage as last worked out, by its first day, in East's order (#1650). */ private kept; private domain; private context; /** * The span's coverage, a week at a time. * * @param domain - The duty row type's domain * @param context - The configuration, kept by identity * @param weeks - The span's weeks, each its first day and the week as drafted * @param primary - The week the inspector reads, by its first day, and its coverage, the pay's costs in it * @returns Each week's coverage, in the span's order */ run(domain: RosterDomain, context: Context, weeks: readonly Pick[], primary: { readonly start: Date; readonly coverage: ReadonlyMap; }): readonly ReadonlyMap[]; } /** A pay's costs, totalled: in all, and by code. */ export interface Costs { readonly total: number; readonly byCode: SortedMap; } /** No costs. */ export declare const NO_COSTS: Costs; /** * The duties' costs totalled, in all and by code (§5.6). * * @param pay - Each duty's costs by code * @param keys - The duties to total * @returns Their total, and by code */ export declare function costsOf(pay: Pay, keys: Iterable): Costs; /** Complete staff and activities remain available to domain checks when Slice hides a row. */ export declare function rosterContext(value: RosterPayload): Context; /** A group's skills: the activities of that group, in the activities' order. */ export declare function groupSkills(value: Pick, group: string): Activity[]; /** The duties: the activities of no group, which every group may assign. */ export declare function duties(value: Pick): Activity[]; /** * What a group's duty may hold: its skills, then the duties — those the * slice's `activities` source shows (#1342), and `keep` always: the duty's * own, as stored and as an edit has it. A duty in no group yet holds a duty * alone (#1548): a group's skill is its own duties'. */ export declare function activityChoices(value: Pick, group: string | undefined, keep?: readonly string[]): Activity[]; /** An activity by its key. */ export declare function activityOf(value: Pick, key: string): Activity | undefined; /** A shift by its key. */ export declare function shiftOf(value: Pick, key: string): Shift | undefined; /** A pattern by its key (#1406). */ export declare function patternOf(value: Pick, key: string): Pattern | undefined; /** * Why a pattern cannot be applied (#1406, P23): other than seven days, or a day naming a shift the Roster has not * configured; `undefined` for one that can. * * @param value - The payload: its shifts * @param pattern - The pattern * @returns The reason, as its card says it: `8 days`, `shift "twilight" isn't configured` */ export declare function patternProblem(value: Pick, pattern: Pattern): string | undefined; /** * A pattern's meta (#1406, §8): how many days it works, and their hours — `5 shifts · 40 h`. * * @param value - The payload: its shifts * @param pattern - The pattern * @returns The days worked, and the hours they run */ export declare function patternSummary(value: Pick, pattern: Pattern): { shifts: number; hours: number; }; /** A shift's colour, resolved (#1406, D6): the fill the theme's palette gives its token, and the ink the shade takes. */ export interface ShiftColor { /** The theme's palette colour, as a CSS value. */ readonly fill: string; /** The ink on it: the dark ink up to the 400 shade, the light ink from 500 — the same in both colour modes. */ readonly ink: string; } /** * A colour token as the theme draws it: `{colors..}` through its CSS variable, the same in both colour * modes, and the ink the shade takes. * * @param token - The token * @returns Its fill and its ink */ export declare function colorTokenCss(token: ValueTypeOf): ShiftColor; /** * A shift's colour, where the app gives one (#1406, D6): the People tiles' and marks' fill. * * @param shift - The shift * @returns Its fill and ink; `undefined` for a neutral shift */ export declare function shiftColor(shift: Shift | undefined): ShiftColor | undefined; /** An instant's hour, as a tile prints it: `06`, or `06:30` where its minutes are not zero. */ export declare function hourText(date: Date): string; /** A shift's hours, as a tile prints them: `06–14`, the end past midnight on the clock. */ export declare function shiftHoursText(shift: Shift): string; /** * The letter a month's mark draws for a shift (#1569): its code's first grapheme — an accented letter whole — or its * first code point where the page has no segmenter. Everything else that draws a shift's code draws it whole. * * @param shift - The shift * @returns Its letter; `""` for no shift, or a shift with no code */ export declare function shiftLetter(shift: Shift | undefined): string; /** * Checks bound configuration without rejecting ordinary staffing warnings. * * @param value - The payload: its lists, and whether a duty may be in no group yet * @returns Why the Roster can't be drawn; `undefined` for a configuration it draws */ export declare function configError(value: Pick & { readonly duty: { readonly roles: Pick; }; }): string | undefined; /** A slot's day — or a place's — a UTC midnight. */ export declare function dayOfSlot(start: Date, slot: Pick): Date; /** * The suggestions the week can take, each in its slot: on one of its days * whose period the Roster may edit — the week's, or the day's (#1550) — a * configured group's and shift's, not dismissed, of a person on the staff who * is off that day. */ export declare function availableProposals(value: RosterValue, week: Week, start: Date, periods: readonly WeekPeriod[]): PlacedProposal[]; /** A slot's target: what the targets hold of it, or nothing — never staffing the record does not hold. */ export declare function requirementOf(week: Week, slot: Slot): Requirement; /** Whether two targets ask the same of a slot. */ export declare function sameTarget(a: Requirement, b: Requirement): boolean; /** A shift's own times on a slot's day: from its start, for its hours — what a duty's own times are drawn against (§5.5, rule 2). */ export declare function shiftTimes(value: Pick, slot: Pick, start: Date): { from: Date; to: Date; } | undefined; /** * Where a duty may start (§5.5, rule 4): from twelve hours before its shift's start on its day to just short of twelve * hours after — the starts its day holds (`rosterDayOf`), so an edit of its times never moves it to another day. * * @param value - The payload: its shifts * @param slot - The duty's slot, or its place * @param start - The week's first day * @returns The span, half open: a start twelve hours after its shift's is the next day's; `undefined` for a shift not configured */ export declare function startReach(value: Pick, slot: Pick, start: Date): { from: Date; to: Date; } | undefined; /** Whether a duty's own times differ from its shift's: what draws them (§5.5, rule 2). */ export declare function ownTimes(value: Pick, a: Assignment, start: Date): boolean; /** * The position a new duty holds: the person's own where it is configured, * else the first position that leads no one, else the first; none for a kind * with no `position` role. */ export declare function positionFor(value: RosterPayload, who: Who): option; /** * Totals for the displayed day or week, always over complete coverage: its slots', and the hours of the duties in no * group yet (#1548), which stand in no slot. * * @param coverage - Each slot's coverage * @param view - The view: its layout and period * @param day - The day in view * @param week - The week as drafted: its duties in no group * @returns The totals */ export declare function viewTotals(coverage: ReadonlyMap, view: RosterView, day: number, week: Week): { days: number; cost: number; filled: number; positions: number; open: number; hours: number; needed: number; }; //# sourceMappingURL=model.d.ts.map