/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * The Inspector's words and figures (`Allocation Spec.md` §9.8, A55–A64, A85, * A86, A89), pure: a bin's, a reservation's, a slot's and a resource's status, * its banners and its facts, the summary's counts, the issues' groups and the * drop list's head — each from e3-ui's figures (the loads, the lines, the * checks) or the fit's answer, in the mock's words and the board's nouns. The * renderer computes no figure of its own. * * @packageDocumentation */ import type { SortedMap, option } from "@elaraai/east"; import { type Grip, type LibraryGrip } from "./drag.js"; import { type Bin, type Context, type Day, type Fit, type FitResult, type Issue, type Load, type ResourceLine, type ResourceRow, type Slot, type TimeStep } from "./model.js"; import { type Noun, type Nouns } from "./nouns.js"; /** A pending answer's line: the fit has not said yet (F2). */ export declare const CHECKING = "checking fits\u2026"; /** The words the inspector is written with. */ export interface InspectorWords { nouns: Nouns; /** A quantity with the board's unit (`21 m³`), and a number without it. */ quantity: (value: number) => string; number: (value: number) => string; /** A lane's label. */ lane: (key: string) => string; /** A resource's load, naming the limit it breaks (A19): e3-ui's. */ load: (fill: number, resource: ResourceRow) => string; } /** A head's status (A56, A60–A62): its word and tone, a draft's ring, and a draft's chip. */ export interface InspectorStatus { word: string; tone: "neutral" | "success" | "warning" | "info"; ring: boolean; pending: "new" | "pending" | undefined; } /** An arrival's code: its label, else its key. */ export declare function codeOf(context: Context, arrival: string): string; /** A bin's code: its arrival's, or the board's `Reserved` for a reservation (A16). */ export declare function binCode(context: Context, bin: Bin, nouns: Nouns): string; /** * A bin's status (A56): what its draft changed — `Added`, `Moved`, * `Allocated` (its resources), `Edited · unsaved` (anything else: its * quantity, its row's own fields), and with no resource `Not linked · unsaved`, as the * mock's — else `Not linked`, `Check` (a resource of it over max or held into * its next job) or `Committed`. * * @param bin - The bin as drafted * @param committed - The bin as the day holds it; `undefined` for a new one * @param sameBin - Whether two bins are the same * @param lines - The lines of the resources it is on * @param nouns - The board's words * @returns Its status */ export declare function binStatus(bin: Bin, committed: Bin | undefined, sameBin: (a: Bin, b: Bin) => boolean, lines: readonly ResourceLine[], nouns?: Nouns): InspectorStatus; /** A reservation's status (A61): `Reserved`, or what its draft did, `Added · unsaved`, `Moved · unsaved`. */ export declare function reservationStatus(bin: Bin, committed: Bin | undefined, sameBin: (a: Bin, b: Bin) => boolean, nouns?: Nouns): InspectorStatus; /** A resource's status (A62): `Check` over max or held into its next job, else `Loading`, `Busy` or `Free`, as its load is. */ export declare function resourceStatus(load: Load, line: ResourceLine): InspectorStatus; /** One issue's banner (A56, A62): the shared banner's status, its word and its sentence. */ export interface InspectorBanner { status: "warning" | "error"; title: string; text: string; } /** A resource as a bin's or its own inspector reads it: its row, its load and its line. */ export interface ResourceAt { row: ResourceRow; load: Load; line: ResourceLine; } /** * The banners of what is inspected (A56, A62): a banner per counted issue — * warning or danger — about the bin (`Not linked`, `Partly allocated`, the * app's), then about each resource it is on, or the resource inspected (`Over * max`, `Under min`, `Overlaps the next job`, the app's); the built-in ones in * the mock's sentences, the app's its title's kind and its detail. * * @param args - The issues, the bin if one is inspected, its resources, the plan day and the words * @returns The banners, in order */ export declare function bannersOf(args: { issues: readonly Issue[]; bin?: { id: string; code: string; } | undefined; resources: readonly ResourceAt[]; day: Date; words: InspectorWords; }): InspectorBanner[]; /** A resource's facts on `88px 1fr` (A58, A62): what held it before, its hold, and its next fill. */ export interface ResourceFacts { before: string; /** Its hold today; `absent` when it holds nothing and is not busy (`not started`). */ hold: { text: string; absent: boolean; }; /** Its next fill; `warn` when its hold runs into it. */ next: { text: string; warn: boolean; }; } /** * A resource's facts (A58, A62), which the inspector labels in the app's words — its prior job, its hold and its next * job: the job before (`job C-3142 · released Fri 7`, or `empty in the plan`), the hold (`Tue 11 to Tue 18 · 8 d`; * `busy until Fri 14`, or `not started`), the next job (`Mon 17 · hold overlaps it by 2 d`, `Wed 19 · 1 d spare`, * with the resource's note, or `none planned to Thu 20`). * * @param at - The resource, its load and its line * @param day - The plan day * @param horizonEnd - The end of the Timeline's resource axis: what `none planned to` names * @param words - The words * @returns Its facts */ export declare function factsOf({ row, load, line }: ResourceAt, day: Date, horizonEnd: Date, words: InspectorWords): ResourceFacts; /** A resource's group line (A58, A62): `Hall B · min 20 m³ · max 40 m³`. */ export declare function groupLine(row: ResourceRow, words: InspectorWords): string; /** A resource's batch line (A58): `Batched · 3 bins · 31 m³`, or `One bin fills it.` */ export declare function batchLine(load: Load, words: InspectorWords): string; /** A bin on a resource today (A58, A62): its time, lane, code and what it puts there, and its tooltip. */ export interface Mate { id: string; time: string; lane: string; code: string; quantity: string; tip: string; } /** * A resource's bins today, by time (A58, A62): each its part there, a * reservation's `reserved`; its tooltip `Bin 3113 · …` (`Bin new` for a new one). * * @param plan - The day as drafted * @param held - The day as the record holds it * @param resource - The resource * @param context - Every arrival and resource * @param words - The words * @returns Its bins */ export declare function matesOf(plan: Day, held: Day | undefined, resource: string, context: Context, words: InspectorWords): Mate[]; /** * A draft's `was` line (A59, A61): `was K-108 · B-2 10:35`, `was not linked · * B-2 10:35`, or `new booking · not in the plan yet`. * * @param committed - The bin as the day holds it; `undefined` for a new one * @param context - Every resource * @param words - The words * @returns The line */ export declare function wasLine(committed: Bin | undefined, context: Context, words: InspectorWords): string; /** * The Bin time stepper's help (A57): `B-1 bins at :15 · ± 1 h, 00–23 on Tue * 11` — the lane's offset, its step, its first and last slot's hours and the * plan day. * * @param slots - The lane's slots, in time order * @param lane - The lane's key * @param every - The slot spacing * @param day - The plan day * @param words - The words * @returns The help line */ export declare function stepHelp(slots: readonly Slot[], lane: string, every: TimeStep, day: Date, words: InspectorWords): string; /** One booking a free slot or a reservation offers (A60, A61): an arrival to book, or a committed bin the drafts removed. */ export interface BookOption { key: string; grip: Extract; code: string; quantity: string; /** Its line: its meta, and `overdue` (in warn) or `removed from plan`. */ line: string; warn: boolean; } /** * What a free slot or a reservation can book (A60, A61), as the Library lists * them (A51): the arrivals still to book, overdue first, then the committed * bins the drafts removed — of the arrivals the narrowing shows (A99). * * @param args - The day as drafted and as the record holds it, every arrival, the plan day, the arrivals shown and the words * @returns The bookings, in order */ export declare function bookOptions(args: { plan: Day; held: Day | undefined; context: Context; day: Date; shown: option>; words: InspectorWords; }): BookOption[]; /** A verdict as a booking's line says it (A61): the fit's reason; refused, `doesn’t fit · …` in warn and Book off; pending, `checking fits…`. */ export declare function verdictLine(verdict: Fit | undefined): { line: string; warn: boolean; enabled: boolean; }; /** One fit a list ranks (A34, A59): its resource, its rank and the fit's reason. */ export interface RankedFit { key: string; rank: number; name: string; why: string; } /** * The fits an answer ranks, in the order given, each its reason (A34, A59). * * @param answer - The fit's answer * @param keys - The resources, best first * @param context - Every resource * @returns The ranked fits */ export declare function rankedFits(answer: FitResult | undefined, keys: readonly string[], context: Context): RankedFit[]; /** The three best other fits of a bin's question, its current resource excepted (A59); `undefined` while the answer is on its way. */ export declare function alternativesOf(answer: FitResult | undefined, current: string | undefined, context: Context): RankedFit[] | undefined; /** One reservation a free slot offers (A60): its resource, what it takes, and the fit's reason after `free` or `loading`. */ export interface ReserveOption { key: string; name: string; range: string; line: string; } /** * The five best resources to reserve a free slot on (A60): the fit's answer * to a reservation in the slot, the free ones first, each best first — of the * resources the narrowing shows (A94). * * @param answer - The fit's answer to placing a reservation in the slot; `undefined` while it is on its way * @param loads - Every resource's load * @param context - Every resource * @param shown - The resources the narrowing shows * @param words - The words * @returns The options, or `undefined` while the answer is on its way */ export declare function reserveOptions(answer: FitResult | undefined, loads: SortedMap, context: Context, shown: option>, words: InspectorWords): ReserveOption[] | undefined; /** One of the summary's counts (A63): its label, its value, its line, and the value's tone. */ export interface SummaryStat { key: string; label: string; value: string; sub: string; tone: "warning" | "brand" | undefined; } /** * The summary's four counts (A63): Bins (`26`, `556 m³ · 0 reserved`), Loading * (`21 of 33`, `10 free · 2 busy`), Issues (`3`, `2 overlaps · 1 over max`, or * `none`), the refusals holding Save among them (#1525), and Changes (`0`, * `all saved`, or `N`, `unsaved · Save is in the toolbar`). * * @param args - The day as drafted and as the record holds it, every load, every issue, how many refusals hold Save, and the words * @returns The counts, in order */ export declare function summaryStats(args: { plan: Day; held: Day | undefined; sameBin: (a: Bin, b: Bin) => boolean; loads: SortedMap; issues: readonly Issue[]; refused?: number; words: InspectorWords; }): SummaryStat[]; /** The summary's line under its title (A63): `3 lanes · 33 resources`. */ export declare function summaryLine(lanes: number, resources: number, nouns: Nouns): string; /** * The narrowing's note (A63): `21 of 33 kilns visible · fits, checks and * totals include all`, each source the narrowing hides rows of; `undefined` * while none does. * * @param sources - Each narrowed source: how many it shows, of how many, in its noun * @returns The note */ export declare function narrowingNote(sources: readonly { shown: number; total: number; noun: Noun; }[]): string | undefined; /** The summary's three hints (A89). */ export declare function summaryHints(nouns: Nouns): string[]; /** One group of the Issues tab (A64): its kind's name, its tone's mark, and its issues. */ export interface IssueGroup { key: string; label: string; tone: "warning" | "danger" | undefined; issues: Issue[]; } /** An issue's kind as its group names it (A64): the built-in kinds' words, the app's own name. */ export declare function kindLabel(issue: Issue): string; /** * The Issues tab's groups (A64): Not linked, Partly allocated, Overlaps the * next job, Over max and Under minimum, then the app's by their kind's name, * as they come — each with every issue of it, counted or not; marked danger, * warning, or not at all. * * @param issues - Every issue, the built-in ones first * @returns The groups that have issues, in order */ export declare function issueGroups(issues: readonly Issue[]): IssueGroup[]; /** An issue's fix's words (A64): `Choose a resource`, `Find a fit`, `Move LD-2205…`. */ export declare function fixLabel(issue: Issue, codeOfBin: (bin: string) => string, nouns: Nouns): string | undefined; /** The drop list's head (A34): what is dragged or picked, and what a drop does. */ export interface DropHead { eyebrow: string; title: string; meta: string; hint: string; /** Whether it lists the fits: an arrival's, a removed bin's, a connector's or a link's drag, or a pick. */ fits: boolean; } /** * The drop list's head (A34, A86): for a resource card, `Resource · K-203 · * Hall B · …`; for a card body, `Move bin · LD-2210 · 32 m³ · between lanes and * hours · its resource stays K-108`; for an arrival, a removed bin, a connector * or a link, `Gaps that fit · LD-2231 · 21 m³ · 8-day hold from Tue 11 · ` and * the answer's `basis` — and the layout's hint, a pick's naming the day's * first free slot. * * @param args - What is dragged or picked, whether a drag is under way, the layout, the day, the quantity placed, the answer's basis, the day's first free slot and the words * @returns The head */ export declare function dropHeadOf(args: { subject: Grip; dragging: boolean; layout: "timeline" | "table"; day: Date; plan: Day; held: Day | undefined; context: Context; loads: SortedMap; lines: ReadonlyMap; quantity: number | undefined; basis: string | undefined; firstFree: { lane: string; at: Date; } | undefined; words: InspectorWords; }): DropHead; //# sourceMappingURL=inspector-model.d.ts.map