/**
 * `GET /api/map` — the repository at module granularity.
 *
 * The Map answers "what is in here and how is it organised" without anybody
 * having drawn a diagram: modules are directories, the arrows between them are
 * the edges the index already holds, and the vertical order falls out of the
 * dependency direction (design spec §3.6). This module produces the *data*;
 * the layering, cycle-breaking and geometry are pure functions in the viewer
 * (`ui/src/lib/map-model.ts`), so toggling tests or selecting a module never
 * costs a round-trip.
 *
 * Three decisions shape the payload, and all three are about not lying:
 *
 * **A module is a directory, not a guess.** `moduleIdFor` maps each indexed
 * file to the first {@link MapQuery.depth} path segments under the chosen root.
 * A file sitting loose in the root gets folded into one `(root files)` box —
 * except a façade (`index.ts`, `lib.rs`, `__init__.py`), which is its own box
 * because it is the thing everything else imports. No clustering, no
 * heuristics about "what belongs together": if two files are in the same
 * directory the repository already said they belong together.
 *
 * **Weight counts edges; layering counts *declared* edges.** A link's `count`
 * is every confident cross-module edge behind it, which is what the reader
 * sees as thickness. Its `declared` count is the subset resolved through an
 * import, a qualified name, an inheritance clause or a typed receiver — and
 * that is what the layout layers on. The difference is not academic: on this
 * repository, bare name matching resolves calls to `run`, `push` and `finish`
 * across unrelated directories, and layering on raw counts puts the storage
 * layer directly under the CLI. Layering on declared edges reproduces the
 * pipeline the project's own docs describe.
 *
 * **Nothing is dropped silently.** Uncertain edges (confidence below
 * {@link UNCERTAIN_BELOW}) are excluded from every count, and how many were
 * excluded rides on the payload so the side panel can say so.
 */
import type { CodeGraph } from '../../index';
import type { EdgeKind, Language } from '../../types';
import { type WireList } from './wire';
/**
 * The edge kinds that count as "module A reaches into module B".
 *
 * `contains` is absent on purpose — a file containing its own symbols is not a
 * dependency, and including it would make every module depend on itself.
 */
export declare const MAP_EDGE_KINDS: readonly EdgeKind[];
/** Id of the bucket loose files fall into. Deliberately not a real directory name. */
export declare function rootFilesId(root: string): string;
export interface WireMapModule {
    /** Directory path, or the `(root files)` bucket, or a façade file's own path. */
    id: string;
    /**
     * What the box says: the id, with a folder chain the repository never forks
     * in written `first/…/last` — Maven's `src/main/java/…/petclinic/owner`
     * rather than all seven segments. Equal to `id` everywhere else.
     */
    label: string;
    files: number;
    symbols: number;
    /** File count by language, most files first. */
    languages: Array<{
        language: Language;
        files: number;
    }>;
    /** More than half its files are tests — drawn dashed, hidden by default. */
    test: boolean;
    /**
     * How many of its files are tool-generated. A module whose files are ALL
     * generated is drawn in ink-4 (design spec §2.6): code nobody wrote by hand
     * and nobody deletes by hand.
     */
    generated: number;
    /** Which of {@link fileList}'s entries are generated, so a row can dim too. */
    generatedFiles: string[];
    /** True when this box is a single file kept out of the root bucket (a façade). */
    facade: boolean;
    /** Its files, capped — what the side panel lists when the module is selected. */
    fileList: WireList<string>;
    /**
     * What a change in here reaches: files OUTSIDE this module holding a direct,
     * confident reference into one of its files, and how many modules those
     * files span.
     *
     * DIRECT, deliberately. The transitive closure was measured first and it is
     * useless on a real repository: any dependency cycle — and a mobile app had
     * nine mutual pairs — saturates it, so every module comes out reaching
     * nearly every file (139–282 of 377, a flat 2× spread that says nothing but
     * "this repo has cycles"). The direct count on the same repository spreads
     * 0–127 and names the modules a reader would name by hand: the shared types
     * at the top, the CLI at zero.
     *
     * The counts are FILES, not symbols: a module is a set of files, and "94
     * files would have to be re-read if this changed" is a claim the index can
     * stand behind. It is a floor on blast radius, not the whole of it — a
     * symbol-level answer for one symbol is what the Symbol view is for.
     */
    dependents: {
        files: number;
        modules: number;
    };
}
export interface WireMapLink {
    source: string;
    target: string;
    /** Every confident cross-module edge behind this link. Drives thickness. */
    count: number;
    /**
     * The subset resolved through an import, a qualified name, an inheritance
     * clause or a typed receiver. Drives the layering — see the module header.
     */
    declared: number;
    /** `count` broken down by edge kind, biggest first. */
    byKind: Array<{
        kind: EdgeKind;
        count: number;
    }>;
    /**
     * The busiest symbol pairs behind the link, at most
     * {@link TOP_PAIRS_PER_LINK}, declared ones first.
     */
    topPairs: Array<{
        from: string;
        to: string;
        count: number;
        declared: number;
    }>;
}
export interface WireMapCycle {
    /** How many files are in the component. `files` may be shorter. */
    size: number;
    /** The files, capped — a 200-file knot is a fact, not a list anybody reads. */
    files: string[];
    /** The modules the cycle passes through, deduped in order. */
    modules: string[];
}
export interface WireMapPayload {
    root: string;
    depth: number;
    /** Every root the selector may offer, this index's own directories. */
    roots: Array<{
        root: string;
        label: string;
        files: number;
    }>;
    modules: WireMapModule[];
    links: WireMapLink[];
    /**
     * File-level circular dependencies — the strongly connected components of
     * the file graph, which is what `findCircularDependencies` reports, computed
     * from one query so it stays affordable on a large index.
     */
    cycles: {
        total: number;
        shown: number;
        truncated: boolean;
        items: WireMapCycle[];
    };
    excluded: {
        /** Cross-module edges left out for being name-only guesses. */
        uncertainEdges: number;
        /** The confidence floor applied. */
        confidenceBelow: number;
    };
    index: {
        lastIndexedAt: number | null;
        edges: number;
        files: number;
    };
    /** How long the aggregation took, and whether this answer came from the cache. */
    timing: {
        elapsedMs: number;
        cached: boolean;
    };
}
export interface MapQuery {
    root: string;
    depth: number;
}
/** Strip a trailing slash and any leading `./`, so `src/` and `src` are one root. */
export declare function normalizeRoot(raw: string | undefined): string;
/**
 * Directories a module boundary never falls on: exactly one subdirectory and
 * no file of their own. A Maven project keeps every line of Java under
 * `src/main/java/org/springframework/samples/petclinic/`, and the first four
 * of those folders split nothing — cutting at any of them draws the whole
 * program as one box, and no depth the reader can pick gets past them. Such a
 * folder joins the level below it, so depth counts folders that fork.
 *
 * Read from every indexed file, tests included, so a module's id does not
 * change when the reader toggles tests. The repository root is never one.
 */
export declare function passThroughDirs(paths: Iterable<string>): Set<string>;
/**
 * Which module a file belongs to, or `null` when it is outside the root.
 *
 * `depth` levels under the root name the module — a level being a folder and
 * the {@link passThroughDirs} that follow it (without them, one level per
 * folder). A file with fewer levels than that is loose in the root: a façade
 * keeps its own box, everything else joins the `(root files)` bucket.
 */
export declare function moduleIdFor(filePath: string, root: string, depth: number, passThrough?: ReadonlySet<string>): {
    id: string;
    facade: boolean;
    label: string;
} | null;
/**
 * The root the map opens on: the directory holding the most non-test symbols.
 *
 * A repository's source almost always lives under one directory (`src`, `lib`,
 * `pkg`, `app`), and opening there is what keeps the default map about the
 * program rather than about its tests, scripts and sibling packages. The
 * fallback is the repository root, which is correct for a flat project.
 *
 * A directory only wins if it holds a clear majority of the symbols — anything
 * less and the honest answer is "this repository has no single source root".
 */
export declare function pickDefaultRoot(files: ReadonlyArray<{
    path: string;
    symbols: number;
    test: boolean;
}>): string;
/**
 * How many segments name a module, when the reader has not said.
 *
 * Depth is not a property of the reader's taste, it is a property of the
 * repository: one level under the root is the right grouping for a project
 * whose directories ARE its modules, and the wrong one for the very common
 * shape where every line of the program lives under a single `src/`. Drawing
 * that project at depth 1 produces the map this rule exists to prevent — a box
 * labelled `src`, holding two thirds of the code, with nothing to say about it.
 *
 * So: take the shallowest depth that is neither dominated by one box worth
 * opening nor too small to be a picture; stop before a deeper one becomes a
 * crowd; and never go past the last level the directory tree actually has.
 *
 * The walk does NOT stop at the first depth that fails to add boxes. A repo
 * packaged as `frontend/src/...` plateaus at two boxes for two levels running
 * before the third splits it, and a rule that gave up on the plateau would
 * draw exactly the picture this function exists to avoid.
 */
export declare function pickDefaultDepth(files: ReadonlyArray<{
    path: string;
    symbols: number;
    test: boolean;
}>, root: string, passThrough?: ReadonlySet<string>): number;
/**
 * The root and depth the map opens on when the reader named neither.
 *
 * A source directory whose files all sit in one folder — Express's `lib/`, an
 * R package's `R/`, an Erlang app's `src/`, fmt's `include/fmt/` — draws as one
 * box at any depth, and a map whose subject is one box has said nothing. The
 * repository around it (that folder beside a CLI, a `src/`, the examples) is
 * then the picture worth opening on, when it draws more than one box.
 */
export declare function pickDefaultView(files: ReadonlyArray<{
    path: string;
    symbols: number;
    test: boolean;
}>, passThrough?: ReadonlySet<string>): {
    root: string;
    depth: number;
};
export declare function resetMapCache(): void;
/**
 * `null` for either field means "nobody said" — the answer picks. Absence has
 * to survive parsing: a depth defaulted to 1 here is indistinguishable from a
 * reader who asked for 1, and {@link pickDefaultDepth} would never run.
 */
export declare function parseMapQuery(query: URLSearchParams): {
    root: string | null;
    depth: number | null;
};
export declare function buildMap(cg: CodeGraph, projectRoot: string, query: URLSearchParams): WireMapPayload;
//# sourceMappingURL=map.d.ts.map