/**
 * ProgramContext type definition and package-resolution helpers.
 *
 * Contains the ProgramContext type and helper functions for resolving
 * package roots, package info, and CLR metadata discovery.
 */
import * as ts from "typescript";
import type { Binding } from "./binding/index.js";
import type { TypeAuthority } from "./type-system/type-system.js";
import type { IrType } from "./types.js";
import type { DotnetMetadataRegistry } from "../dotnet-metadata.js";
import type { BindingRegistry } from "../program/bindings.js";
import type { ClrBindingsResolver } from "../resolver/clr-bindings-resolver.js";
import type { SurfaceMode } from "../program/types.js";
import type { Diagnostic } from "../types/diagnostic.js";
import type { DeclarationModuleAlias } from "../program/declaration-module-aliases.js";
/**
 * ProgramContext — Per-compilation context owning all semantic state.
 *
 * This context object carries shared resources through the converter chain,
 * eliminating the need for global singletons.
 *
 * INVARIANT: One program → one context. No global state.
 */
export type ProgramContext = {
    /**
     * Project root used for package/module resolution.
     */
    readonly projectRoot: string;
    /**
     * Source root of the current app graph.
     */
    readonly sourceRoot: string;
    /**
     * Authoritative @tsonic package roots participating in the active wave.
     */
    readonly authoritativeTsonicPackageRoots: ReadonlyMap<string, string>;
    /**
     * Ambient declaration-module aliases (for example `node:http` -> `@tsonic/nodejs/http.js`).
     */
    readonly declarationModuleAliases: ReadonlyMap<string, DeclarationModuleAlias>;
    /**
     * Root namespace for generated module/type names.
     */
    readonly rootNamespace: string;
    /**
     * Selected language surface mode for this compilation.
     */
    readonly surface: SurfaceMode;
    /**
     * TypeScript checker for symbol-only queries in converter-time analyses.
     *
     * This must never be used for computed type inference APIs (getTypeAtLocation, etc.).
     */
    readonly checker: ts.TypeChecker;
    /**
     * Supported generic function value symbols for deterministic monomorphic callable contexts.
     *
     * These are collected once for the whole compilation so expression conversion can
     * reuse the same authoritative symbol set without re-scanning source files.
     */
    readonly genericFunctionValueSymbols: ReadonlySet<ts.Symbol>;
    /**
     * Raw TypeScript compiler options for syntax-level module resolution helpers.
     */
    readonly tsCompilerOptions: ts.CompilerOptions;
    /**
     * Closed-world source files keyed by normalized absolute path.
     */
    readonly sourceFilesByPath: ReadonlyMap<string, ts.SourceFile>;
    /**
     * Binding layer for symbol resolution.
     *
     * Provides resolveIdentifier, resolveCallSignature, etc.
     */
    readonly binding: Binding;
    /**
     * TypeSystem for all type queries (Alice's spec).
     *
     * This is the ONLY source for type information. Converters should use
     * TypeSystem methods instead of accessing TypeRegistry/NominalEnv directly.
     */
    readonly typeSystem: TypeAuthority;
    /**
     * .NET metadata registry for imported types.
     */
    readonly metadata: DotnetMetadataRegistry;
    /**
     * CLR bindings from tsbindgen.
     */
    readonly bindings: BindingRegistry;
    /**
     * CLR namespace resolver for import-driven discovery.
     */
    readonly clrResolver: ClrBindingsResolver;
    /**
     * Lexical type environment for deterministic flow typing.
     *
     * Used for:
     * - Typing unannotated lambda parameters within their body (deterministic, TS-free)
     * - Flow narrowing (e.g. `instanceof`) within control-flow branches
     *
     * Keyed by DeclId.id (not by identifier text) so shadowing is always correct.
     */
    readonly typeEnv?: ReadonlyMap<number, IrType>;
    /**
     * Lexical flow environment for property / access-path narrowings.
     *
     * Keyed by a stable serialized access path (e.g. `decl:42.foo` or `this.bar`)
     * so negative-branch narrowing can survive for property reads like
     * `typeof this.value === "string"` or `Array.isArray(obj.items)`.
     */
    readonly accessEnv?: ReadonlyMap<string, IrType>;
    /**
     * IR conversion diagnostics emitted by converters (non-TypeSystem).
     *
     * Converters should record deterministic, airplane-grade failures here
     * instead of guessing (e.g., ambiguous CLR bindings).
     *
     * Collected by `buildIr()` and treated as compilation errors.
     */
    readonly diagnostics: Diagnostic[];
    /**
     * Synthetic `this` type for object-literal method/accessor conversion.
     *
     * When converting object literal behavior members, `this` does not refer to an
     * enclosing class. It refers to the synthesized object shape itself.
     */
    readonly objectLiteralThisType?: IrType;
};
export declare const getCommonAncestor: (leftPath: string, rightPath: string) => string;
export declare const findPackageRootForFile: (fileName: string, projectRootResolved: string, packageRootCache: Map<string, string | undefined>) => string | undefined;
export declare const getPackageInfo: (pkgRoot: string, packageInfoCache: Map<string, {
    readonly name: string | undefined;
    readonly keywords: readonly string[];
    readonly peerDependencies: Readonly<Record<string, string>>;
} | undefined>) => {
    readonly name: string | undefined;
    readonly keywords: readonly string[];
    readonly peerDependencies: Readonly<Record<string, string>>;
} | undefined;
export declare const packageHasClrMetadata: (pkgRoot: string, _packageInfoCache: Map<string, {
    readonly name: string | undefined;
    readonly keywords: readonly string[];
    readonly peerDependencies: Readonly<Record<string, string>>;
} | undefined>, packageHasMetadataCache: Map<string, boolean>) => boolean;
//# sourceMappingURL=program-context-types.d.ts.map