import type { ColdCode } from "../core/types.js"; import type { Versionage } from "../tables/table-types.js"; import { Mapper, type MapperInit, type MapperMap, type MapperValue } from "./mapper.js"; type SadMap = MapperMap; /** * `Compactor` builds on `Mapper` by adding the recursive tree semantics needed * for ACDC-style compact/disclose behavior. * * Read the classes in this order: * 1. `Mapper` explains how one map becomes one native map-group. * 2. `Compactor` explains how a tree of saidive maps becomes compact leaves, * compact branches, and partially re-expanded disclosure variants. * * Boundary rule: * - this is the hierarchical map-disclosure mechanism * - it is not the same thing as fixed-field blinded disclosure in * `disclosure.ts` */ /** * `Compactor` extends `MapperInit` with the option to eagerly run the compact / * expand lifecycle during construction. */ export interface CompactorInit extends MapperInit { compactify?: boolean; } /** * CESR-native compactable map primitive. * * Maintainer mental model: * a `Compactor` is a `Mapper` plus the tree-walking utilities needed to turn * nested saidive maps into their "most compact" branch form and then re-expand * them into readable partial-disclosure variants. `leaves` records the saidive * map nodes discovered during tracing; `partials` records staged re-expansions. */ export declare class Compactor extends Mapper { /** Leaf-path index populated by `trace()`: dotted path -> saidified leaf mapper. */ leaves: Record; /** Partially re-expanded disclosure variants built by `expand()`. */ partials: Record | null; /** * Construct one compactable map primitive. * * If `compactify=true` and the input starts from semantic `mad`, the * constructor eagerly runs the compact + expand lifecycle so callers * immediately get both the compact current state and readable partials. */ constructor(init?: CompactorInit); /** Primary SAID of the current map state, if its configured saidive label is present. */ get said(): string | null; /** * True when the current map is fully compacted. * * `true` means the root map itself is a leaf and its own saidive value is the * compact representation. `false` means there are leaves but at least one * branch is still expanded. `null` means the map tree has no saidive leaves. */ get iscompact(): boolean | null; /** Return the nested tail value located at dotted `path`, or `null` when absent. */ getTail(path: string, mad?: SadMap | null): MapperValue | null; /** * Return the enclosing map and tail label for dotted `path`. * * Example: * path `.a.address` => returns the map stored at `.a` plus tail `"address"`. * path `` (top level) => returns `[null, ""]`. */ getMad(path: string, mad?: SadMap | null): [SadMap | null, string | null]; /** * Walk the nested map tree and index every saidive leaf by dotted path. * * When `saidify=true`, each leaf map is first rebuilt as a `Mapper` with * `makify=true` so its leaf SAID is computed before the path is recorded. */ trace(saidify?: boolean): string[]; /** Apply the most-compact branch reduction recursively until the root is compact or no leaves exist. */ compact(): void; /** * Build readable partial-disclosure variants by progressively re-expanding compact leaves. * * `greedy=true` mirrors KERIpy’s preferred order: expand deeper leaves first * so each staged variant reveals as much structure as possible per step. */ expand(greedy?: boolean): void; private _trace; private _hasSaid; } /** * Parse one CESR-native map body/group and hydrate it as a `Compactor`. * * Example: * a native section like `-GAB0J_dE...0J_x-GA...` becomes a `Compactor` whose * `.mad` is the readable nested object and whose `.qb64` is the exact native * map-group bytes used on the wire. */ export declare function parseCompactor(input: Uint8Array, version: Versionage, cold: Extract): Compactor; export {}; //# sourceMappingURL=compactor.d.ts.map