import type CodecPort from "../../../ports/CodecPort.ts";
import type TrieGeometry from "./TrieGeometry.ts";
/**
 * The wire-format version this codec emits and accepts.
 *
 * A breaking change to the leaf layout bumps this number; the
 * deserializer rejects unrecognized values with
 * `E_TRIE_LEAF_VERSION`.
 */
export declare const TRIE_LEAF_WIRE_VERSION = 1;
/**
 * Single leaf entry: route-key suffix, element ID, dots, tombstoned
 * dots.
 *
 * The `routeKeySuffix` is the bytes of the element's route key
 * below the leaf's trie depth — the prefix is already encoded by
 * the trie path and is not repeated in the leaf.
 *
 * `dots` and `tombstonedDots` are observed / retracted dots for
 * the element within the ORSet, encoded as string tokens by the
 * higher-level ORSet layer. This class does not parse or interpret
 * them; it transports them through the codec.
 */
export interface TrieLeafEntry {
    readonly routeKeySuffix: Uint8Array;
    readonly element: string;
    readonly dots: ReadonlySet<string>;
    readonly tombstonedDots: ReadonlySet<string>;
}
/**
 * Runtime-backed leaf node of the shadow trie.
 *
 * A leaf holds a sorted array of entries (by `routeKeySuffix`,
 * byte-lex). Construction validates sort order and freezes the
 * instance. `binarySearch` returns the matching index or `-1`.
 * `serialize` / `deserialize` round-trip through a `CodecPort`
 * adapter via a versioned CBOR envelope.
 *
 * The leaf owns the geometry it was constructed under so it can
 * answer split/merge questions without the caller threading the
 * geometry separately.
 */
export default class TrieLeaf {
    readonly geometry: TrieGeometry;
    private readonly sortedEntries;
    constructor(entries: ReadonlyArray<TrieLeafEntry>, geometry: TrieGeometry);
    /**
     * Number of entries in the leaf.
     */
    size(): number;
    /**
     * Accessor for the sorted entry array. Returns the frozen array
     * the leaf was constructed with — the caller is expected not to
     * mutate it.
     */
    entries(): ReadonlyArray<TrieLeafEntry>;
    /**
     * Binary search for an exact route-key-suffix match.
     *
     * Returns the index of the matching entry or `-1` if the suffix
     * is not present. Comparison is byte-lex over `Uint8Array`.
     */
    binarySearch(suffix: Uint8Array): number;
    /**
     * Returns true when the leaf has exceeded the geometry's capacity.
     */
    requiresSplit(geometry: TrieGeometry): boolean;
    /**
     * Returns true when the leaf has dropped below the geometry's
     * merge floor.
     */
    requiresMerge(geometry: TrieGeometry): boolean;
    /**
     * Serialize this leaf to CBOR bytes via the supplied codec.
     *
     * The wire format is a versioned envelope; see
     * `TRIE_LEAF_WIRE_VERSION` for the current value.
     */
    serialize(codec: CodecPort): Uint8Array;
    /**
     * Decode bytes into a `TrieLeaf` under the supplied geometry.
     *
     * Validates the envelope version, the envelope shape, and the
     * entries' sort order. Raises `TrieLeafError` with a typed code
     * on any violation.
     */
    static deserialize(bytes: Uint8Array, geometry: TrieGeometry, codec: CodecPort): TrieLeaf;
}
