/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ import { type Coverage, type RosterValue, type Shift, type Slot, type Week } from "./model.js"; /** A week of the span, as the work requirement reads it: its targets, each slot's coverage over it, and its duties in no group. */ export interface DemandWeek { /** The week's targets, by slot. */ readonly requirements: Week["requirements"]; /** Each slot's coverage over the week. */ readonly coverage: ReadonlyMap; /** Its duties in no group yet (#1548): each day's hours by shift's key, the week's first day first ({@link looseOf}). */ readonly loose?: readonly ReadonlyMap[] | undefined; } /** A shift's day's duties in no group yet (#1548): their hours, split as a slot's coverage splits its own. */ export interface LooseHours { /** The permanent staff's. */ readonly permanent: number; /** Agency staff's. */ readonly agency: number; /** The agencies' requests'. */ readonly requested: number; } /** Hours over a set of slots: those needed against those rostered, and what the slots are short, each its own. */ export interface DemandFigures { /** * Whether a slot of the set has a target with work to it: hours needed or rostered. A target needing no hours, none * rostered, is no target, as the Shifts layout's `No work` reads it. Where none has, its cell says so and draws no bar * (A3.6). */ readonly target: boolean; /** The hours the slots' targets need. */ readonly needed: number; /** Every duty's hours on the slots: the permanent staff's, agency staff's and the agencies' requests'. */ readonly rostered: number; /** The permanent staff's part of them. */ readonly permanent: number; /** Agency staff's part of them. */ readonly agency: number; /** The agencies' requests' part of them. */ readonly requested: number; /** The hours short, each slot's own summed: no slot's surplus nets another's shortfall (K4). */ readonly short: number; /** How many of the slots are short. */ readonly shortSlots: number; } /** A skill's hours over a set of slots: those its duties are assigned against those the slots' targets need, and what the slots are short of it. */ export interface SkillFigures { /** The hours the targets need of the skill. */ readonly needed: number; /** The hours of duties assigned the skill. */ readonly assigned: number; /** The hours of it short, each slot's own summed: no slot's surplus nets another's shortfall (K4). */ readonly short: number; } /** A skill row under an open lane (A4): the skill's hours each day and over the span. */ export interface DemandSkill { /** The skill's key. */ readonly skill: string; /** Each day's, the span's first day first, seven a week: `undefined` where none of the day's slots needs hours of the skill or has any assigned. */ readonly days: readonly (SkillFigures | undefined)[]; /** The span's. */ readonly total: SkillFigures; } /** A lane (A3): a shift a target of the scope names in the span with hours needed or rostered on some day of it, its slots each day and over the span. */ export interface DemandLane { /** The shift. */ readonly shift: Shift; /** Each day's, the span's first day first, seven a week: the shift's slots of the scope's groups that day. */ readonly days: readonly DemandFigures[]; /** The span's. */ readonly total: DemandFigures; /** * Its skill rows: one a key its slots' targets need hours of or have assigned, in the activities' order (A4.1), then * every other key, in key order (#1678) — so they add up to the lane where the targets give no hours needed of their own. */ readonly skills: readonly DemandSkill[]; } /** A scope's work requirement over the span: a group's, or every group's where the layout draws no bands. */ export interface Demand { /** Its lanes: one a shift a target of the scope names in the span with hours needed or rostered on some day of it, in the shifts' order (A3.1); none without one. */ readonly lanes: readonly DemandLane[]; /** Each day's over every slot of the scope, the span's first day first (A2.2): a week's eyebrow's figures. */ readonly days: readonly DemandFigures[]; /** Each week's over every slot of the scope (A2.2): a month's eyebrow's figures. */ readonly weeks: readonly DemandFigures[]; /** The span's over every slot of the scope: the band's figures (A1.2). */ readonly total: DemandFigures; } /** * A day's mark in a month's lane or skill row (A3.5, A4.4): its state — off where it has no target (a skill's, where * none of the day's slots needs it), short where any of its slots is, requested where requests make up part of its * hours, else covered — and the difference its figure says. */ export interface DemandMark { readonly state: "off" | "short" | "requested" | "covered"; /** The difference it states ({@link stated}): what its slots are short, below zero, where any is; else the hours over. */ readonly difference: number; } /** * Rostered less needed, a hair either side of zero none at all. * * @param rostered - The hours rostered * @param needed - The hours needed * @returns The difference: below zero where short, above where over, zero where exact */ export declare function difference(rostered: number, needed: number): number; /** * The difference a figure states (K4, B3.2): where any of its slots is short, what they are short, each slot's own * summed, below zero — never their net, which would let one slot's surplus fill another's shortfall — else the hours * over, or none. * * @param have - The hours rostered, or a skill's hours assigned * @param needed - The hours needed * @param short - What its slots are short, each slot's own summed * @returns The difference: below zero where short, above where over, zero where exact */ export declare function stated(have: number, needed: number, short: number): number; /** * How a difference is toned (K3): the warning where short, muted where over, positive where exact. * * @param d - The difference, as {@link difference} gives it * @returns Its tone */ export declare function toneOf(d: number): "short" | "over" | "exact"; /** * A difference as its figure reads (A3.3): `+4`, `−6` with a true minus, and nothing at zero — or `zero` where a figure * always shows, as the band's `+0`. * * @param number - The locale's number formatter * @param d - The difference * @param zero - What zero reads; nothing by default * @returns The figure */ export declare function signed(number: (n: number) => string, d: number, zero?: string): string; /** * A difference as a day's label says it to a screen reader, after its hours (K4): `, 2 short`, `, 13 over`, and * nothing at zero. The label stands in for the figures it holds, and its hours alone cannot say a stated shortfall: a * day 2 short in one group and 4 over in another has more hours rostered than needed. * * @param number - The locale's number formatter * @param d - The difference it states ({@link stated}) * @returns What follows the hours in its label */ export declare function differenceSaid(number: (n: number) => string, d: number): string; /** * A lane's day as a month's mark draws it (A3.5): off with no target; short where any of its slots is, by what they are * short (K4); requested where the agencies' requests make up part of its hours, which count as rostered, as the week's * bar draws them dashed; else covered, over by its difference or exact. * * @param f - The lane's day * @returns Its mark */ export declare function laneMark(f: DemandFigures): DemandMark; /** * A skill row's day as a month's mark draws it (A4.4): off where none of the day's slots needs the skill; short where * any of its slots is short of it, by what they are short (K4); else covered. * * @param f - The skill's day, `undefined` where none of its slots needs it * @returns Its mark */ export declare function skillMark(f: SkillFigures | undefined): DemandMark; /** A part of a day's bar (A3.3): the permanent staff's, agency staff's or the agencies' requests' hours, or what is open. */ export interface BarPart { readonly kind: "permanent" | "agency" | "requested" | "open"; /** Where it starts, in hours from the bar's start. */ readonly left: number; /** Its hours. */ readonly width: number; } /** A day's bar (A3.4): its parts, in hours, and the hours its whole length stands for. */ export interface DemandBar { readonly parts: readonly BarPart[]; /** The hours of its whole length: the larger of those needed and those its parts reach, an hour at least. */ readonly scale: number; } /** * A day's bar (A3.3, A3.4) — a lane's day's, or a slot's coverage's: the permanent staff's, agency staff's and the * agencies' requests' parts from its start, each it has some of, then what its slots are short open after them, each * slot's own summed (K4) — so a day short in one slot and over in another draws its hours past the needed tick and its * shortfall open after them — scaled to the larger of the hours needed and those its parts reach. A slot's bar, its * shortfall its own, is open from its hours to the tick. * * @param hours - Its hours: the permanent staff's, agency staff's, the agencies' requests' and those needed * @param short - What its slots are short, each slot's own summed * @returns Its parts and its scale */ export declare function barOf(hours: Pick, short: number): DemandBar; /** * How far a day's mark by month fills as a cup (ruled 8 Nov 2026), from the bottom, each level a share of its height: * the permanent staff's hours first, then agency staff's, the agencies' requests' on top — a skill's, its hours * assigned, all three levels its one — full where none of its slots is short. */ export interface DemandCup { /** Where the permanent staff's part ends. */ readonly permanent: number; /** Where agency staff's part ends. */ readonly agency: number; /** Where the fill ends, the agencies' requests' part with it: the hours rostered of those needed, at most the whole. */ readonly fill: number; } /** * A lane's day as its cup fills by month (ruled 8 Nov 2026): to the share of its hours needed its slots meet — full * where none of them is short, and where any is, open above by what they are short, each slot's own (K4), whatever * another slot is over — its parts the permanent staff's, agency staff's and the agencies' requests' in proportion to * its hours rostered; empty with no target, or with no hours of either. A day of one slot fills as its bar by week * draws it, each level ending where the bar's part does: a short day to its hours rostered of needed, a day covered or * over full, its parts in proportion. * * @param f - The lane's day * @returns Its cup's levels */ export declare function laneCup(f: DemandFigures): DemandCup; /** * The share of a skill's hours needed its slots meet (K4): those needed less what each slot is short of it, so no * slot's surplus fills another's shortfall — a skill row's bar by week and its cup by month fill to it. * * @param f - The skill's day, or its week * @returns The share, from 0 to 1; all of it where its slots need none */ export declare function skillMet(f: SkillFigures): number; /** * A skill row's day as its cup fills by month (ruled 8 Nov 2026): to the share of its hours needed its slots meet * ({@link skillMet}), full where none is short of it, as the day's bar by week draws it; empty where none of the day's * slots needs the skill. * * @param f - The skill's day, `undefined` where none of its slots needs it * @returns Its cup's levels, each the one level */ export declare function skillCup(f: SkillFigures | undefined): DemandCup; /** * A week's duties in no group yet (#1548), as the one block over every group counts them: each day's hours by its * shift's key, the week's first day first, split as a slot's coverage splits its own — an agency person's as agency * staff's, a request's as the agencies'. * * @param value - The payload: its people, each marked agency staff or not * @param week - The week as drafted * @returns Each day's hours, by shift */ export declare function looseOf(value: Pick, week: Week): readonly ReadonlyMap[]; /** * A scope's work requirement over the span (#1568): a lane a shift a target of the scope names in any of the span's * weeks, with hours needed or rostered on some day of it — a target needing no hours, none rostered, is no target, as * the Shifts layout's `No work` reads it — its days' and its span's hours summed over the scope's groups' slots — each * slot's as the Shifts layout draws it — and its skill rows; and the scope's days', weeks' and span's over every one of * its slots, a shift with no target's included, as the Shifts layout's band sums them. With `loose`, each shift's day counts the week's duties in * no group there too (#1548): the one block over every group's. * * @param value - The payload: its shifts and activities, in their orders * @param weeks - The span's weeks, its first first: each one's targets, coverage and duties in no group * @param groups - The scope's groups: a band's own, or every group where the layout draws no bands * @param loose - Whether the scope counts the duties in no group: the one block's * @returns The scope's lanes and figures */ export declare function demandOf(value: Pick, weeks: readonly DemandWeek[], groups: readonly string[], loose?: boolean): Demand; /** * Coverage summed over slots (#1568): a shift's day across the groups, as the inspector draws it — positions, people, * hours and cost added, a lead or a trainer where any slot has one, and each key's line summed over the slots whose * targets need it, in the lines' order ({@link lineOrder}), its holders and capacity where any slot counts them. With `loose`, the * hours of the duties in no group there count as rostered too, as the one block's lane counts them (#1548): they fill * no position. * * @param value - The payload: its activities, in their order * @param list - The slots' coverage * @param loose - The shift's day's duties in no group yet, where the sum counts them * @returns Their sum, a coverage the coverage detail draws as it draws a slot's */ export declare function summedCoverage(value: Pick, list: readonly Coverage[], loose?: LooseHours): Coverage; //# sourceMappingURL=demand.d.ts.map