/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ import type { ItemRoles, SchematicDrawn, SchematicRef, ZoneRoles } from "./canvas/drawn.js"; import type { SchematicLayerState } from "./canvas/layers.js"; import type { SchematicValue } from "./data.js"; import type { SortDrafts } from "./drafted.js"; /** Why the drawing's Details counts none of a sort or a kind: a hidden layer, the ends a link or a net joins, or the filters. */ export type SchematicUncounted = "layer" | "ends" | "filters"; /** * A count the drawing's Details says (see the module docs): a number; one whose read is in flight — a placeholder in its * place; or one no read can say, and why. */ export type SchematicDrawingCount = { readonly kind: "counted"; readonly n: number; } | { readonly kind: "reading"; } | { readonly kind: "uncounted"; readonly why: SchematicUncounted; }; /** A count in flight. */ export declare const COUNT_READING: SchematicDrawingCount; /** * A count, as a number says it. * * @param n - The number * @returns The count */ export declare function counted(n: number): SchematicDrawingCount; /** * A count no read can say. * * @param why - Why * @returns The count */ export declare function uncounted(why: SchematicUncounted): SchematicDrawingCount; /** One item kind, as the drawing's Details counts it. */ export interface SchematicKindCount { /** Its slot. */ readonly slot: string; /** Its name (`Rack`). */ readonly name: string; /** Its items drawn: placed, its narrowing's and on no hidden layer — a kind read by area's counted by its source. */ readonly drawn: SchematicDrawingCount; } /** What the drawing's Details counts. */ export interface SchematicCounts { /** Each item kind's items drawn, in the order the Schematic lists them. */ readonly kinds: readonly SchematicKindCount[]; /** The zones drawn; `undefined` with no zone kind. */ readonly zones: SchematicDrawingCount | undefined; /** The links drawn — each between two items drawn; `undefined` with no link kind. */ readonly links: SchematicDrawingCount | undefined; /** The nets drawn — each with a member drawn on either side; `undefined` with no net kind. */ readonly nets: SchematicDrawingCount | undefined; } /** What the Schematic declares, as the drawing's Details counts it: its kinds, by sort. */ export interface SchematicCountedKinds { /** The item kinds: each its slot and its name. */ readonly items: readonly { readonly key: string; readonly name: string; }[]; /** Whether it has zone kinds. */ readonly zones: boolean; /** Whether it has link kinds. */ readonly links: boolean; /** Whether it has net kinds. */ readonly nets: boolean; /** The kinds read by area, by slot (#1393): each counted by its source, as given, never by what its window draws. */ readonly areas?: ReadonlySet | undefined; /** Whether a link kind may join an item of a kind read by area: then no link is counted. */ readonly linksByArea?: boolean | undefined; /** Whether a net kind may join an item of a kind read by area: then no net is counted. */ readonly netsByArea?: boolean | undefined; } /** * What the drawing's Details counts of a drawing (see the module docs). * * @param kinds - The Schematic's kinds * @param drawn - What the canvas draws * @param layers - What its layers hide * @param areaCounts - Each kind read by area's count, by its slot, its drafts in place: in flight while it has none * @returns The counts */ export declare function schematicCounts(kinds: SchematicCountedKinds, drawn: SchematicDrawn, layers: SchematicLayerState, areaCounts?: ReadonlyMap): SchematicCounts; /** A kind read by area, as its count is drafted: its slot, and its sort — an item's rows may have no position, a zone's always have one. */ export interface SchematicAreaCountedKind { /** Its slot. */ readonly key: string; /** Its sort. */ readonly sort: "items" | "zones"; } /** * Each kind read by area's count with its drafts in place (#1393): its stored rows' count, and for each row a draft holds * that its narrowing holds — by the row its session began from — one more where the draft has a position and the row it * began from had none, one fewer the other way, and one fewer where the draft deletes a row that had one; a row a gesture * made, one more where it has a position, the narrowing's or not, as it draws. A count in flight, or one no read can say, * stays so; and while a hidden layer may hold some of a kind's rows, no read can say how many it draws. * * @param kinds - The kinds read by area * @param stored - Each one's stored rows' count, by its slot (`area-counts.ts`) * @param drafts - The item kinds' and the zone kinds' drafts * @param held - Whether a kind's narrowing holds a drafted row, by the row its session began from: `false` leaves it out; * `undefined` — nothing narrows the kind, or its answer is in flight — counts it * @param began - Whether the row a deleted draft's session began from had a position; `undefined` for one a gesture made * @param layerHidden - Whether a layer is hidden * @returns Each kind's count, by its slot */ export declare function draftedAreaCounts(kinds: readonly SchematicAreaCountedKind[], stored: ReadonlyMap, drafts: { readonly items: SortDrafts; readonly zones: SortDrafts; }, held: (ref: SchematicRef) => boolean | undefined, began: (ref: SchematicRef) => boolean | undefined, layerHidden: boolean): ReadonlyMap; /** A record's commits, newest first, as a kind's `history` reads them. */ type History = Extract["value"]; /** A kind's record whose commits say when it was last saved: one bound with its patch door. */ export interface SchematicSavedRecord { /** The kind's slot. */ readonly slot: string; /** The kind's name (`Rack`). */ readonly name: string; /** Its record's commits, newest first. */ readonly history: History; } /** * The kinds whose records say when they were last saved: each bound with its * patch door, whose commits it reads — in the Schematic's order of its sorts, * items, zones, links and nets. * * @param value - The payload * @returns Each such kind's record */ export declare function savedRecords(value: SchematicValue): SchematicSavedRecord[]; export {}; //# sourceMappingURL=counts.d.ts.map