import { AgencyComment, AgencyMultiLineComment, AgencyNode, AgencyProgram, Assignment, DebuggerStatement, InterruptStatement, Literal, NewLine, ParallelBlock, Scope, SeqBlock, TypeAlias, VariableType } from "../types.js";
import { AccessChainElement, ValueAccess } from "../types/access.js";
import { BlockArgument } from "../types/blockArgument.js";
import { AgencyArray, AgencyObject } from "../types/dataStructures.js";
import { FunctionCall, FunctionDefinition } from "../types/function.js";
import { GraphNodeDefinition } from "../types/graphNode.js";
import { IfElse } from "../types/ifElse.js";
import { ImportNameType, ImportNodeStatement, ImportStatement } from "../types/importStatement.js";
import { ExportFromStatement } from "../types/exportFromStatement.js";
import { MatchBlock } from "../types/matchBlock.js";
import { ReturnStatement } from "../types/returnStatement.js";
import { GotoStatement } from "../types/gotoStatement.js";
import { ForLoop } from "../types/forLoop.js";
import { WhileLoop } from "../types/whileLoop.js";
import { AgencyConfig } from "../config.js";
import { MessageThread } from "../types/messageThread.js";
import { Skill } from "../types/skill.js";
import { BinOpArgument, BinOpExpression, Operator } from "../types/binop.js";
import { Keyword } from "../types/keyword.js";
import { HandleBlock } from "../types/handleBlock.js";
import { Tag } from "../types/tag.js";
import { NewExpression } from "../types/newExpression.js";
import { BindingPattern, MatchPattern } from "../types/pattern.js";
export declare class AgencyGenerator {
    protected graphNodes: GraphNodeDefinition[];
    protected generatedStatements: string[];
    protected generatedTypeAliases: string[];
    protected typeAliases: Record<string, VariableType>;
    protected functionsUsed: Set<string>;
    protected importNodes: ImportStatement[];
    protected importedNodes: ImportNodeStatement[];
    /** Comments / blank lines at the very top of the file that must stay
     *  above the (sorted) imports block — e.g. file-level `// @tc-nocheck`,
     *  shebangs, module docstrings. Populated by `partitionImports()`. */
    protected importHeaderNodes: AgencyNode[];
    /** Comments attached to each import statement (no blank line between
     *  them and the import). Travel with the import when imports get
     *  sorted, so `// @tc-ignore` above an import keeps suppressing it. */
    protected importAttachedComments: Map<ImportStatement | ImportNodeStatement, AgencyNode[]>;
    protected functionDefinitions: Record<string, FunctionDefinition>;
    protected currentScope: Scope[];
    protected program: AgencyProgram | null;
    protected agencyConfig: AgencyConfig;
    private indentLevel;
    private indentSize;
    private debug;
    /**
     * When true, imports render in-place (in their original source position)
     * rather than being hoisted to the top of the file and sorted. Used by
     * `agency literate weave`, which needs to render the file in source
     * order so the prose / code alternation matches what the author wrote.
     */
    protected preserveOrder: boolean;
    constructor(args?: {
        config?: AgencyConfig;
        preserveOrder?: boolean;
    });
    protected trace(methodName: string, result: string): string;
    configDefaults(): Partial<AgencyConfig>;
    generate(program: AgencyProgram): {
        output: string;
    };
    /**
     * Split the node stream into three pieces:
     *
     *   1. `importHeaderNodes` — contiguous comments/blank lines at the
     *      very top of the file (before any code or any import-attached
     *      comment). These render unchanged above the sorted imports block.
     *   2. Imports + comments attached to each one — tracked in
     *      `importAttachedComments`. A comment is "attached" iff it sits
     *      directly above its import with no blank line between them. This
     *      keeps `// @tc-ignore` above an import even when the import is
     *      moved by sorting.
     *   3. Everything else — returned as the new node stream for the
     *      remaining passes to process normally.
     *
     * Imports themselves are kept in `program.nodes` (returned here) so the
     * existing collection pass for `importNodes` / `importedNodes` still
     * sees them. The render path skips them because `processNode` for an
     * import returns "".
     */
    private partitionImports;
    /**
     * Render the top-of-file header (comments + blank lines that sit above
     * the imports block). Returns an empty string when there are none.
     */
    private renderImportHeader;
    addIfNonEmpty(str: string, lines: string[]): void;
    protected preprocessAST(): void;
    protected generateBuiltins(): string;
    protected generateImports(): string;
    protected preprocess(): string;
    protected postprocess(): string;
    protected collectFunctionSignature(node: FunctionDefinition): void;
    protected processGraphNodeName(node: GraphNodeDefinition): void;
    processNode(node: AgencyNode): string;
    private processNodeInner;
    protected processInterruptStatement(node: InterruptStatement): string;
    protected needsParensLeft(child: BinOpArgument, parentOp: Operator): boolean;
    protected needsParensRight(child: BinOpArgument, parentOp: Operator): boolean;
    protected startScope(scope: Scope): void;
    protected endScope(): void;
    protected getCurrentScope(): Scope;
    protected isAgencyFunction(functionName: string, context: "valueAccess" | "functionArg" | "topLevelStatement"): boolean;
    private indent;
    private increaseIndent;
    private decreaseIndent;
    private indentStr;
    private wrapList;
    private renderParams;
    private stringifyProp;
    protected aliasedTypeToString(aliasedType: VariableType): string;
    protected processTypeAlias(node: TypeAlias): string;
    /**
     * Format the `<T, U = string, ...>` chunk of a generic alias declaration.
     * Returns an empty string when there are no type params.
     */
    private formatTypeParams;
    /**
     * Format the `(low: number, high: number = 10)` chunk of a
     * value-parameterized alias declaration. Returns an empty string when
     * there are no value params.
     */
    private formatValueParams;
    protected processAssignment(node: Assignment): string;
    /**
     * Format a pattern AST node back into Agency pattern syntax. Used by the
     * formatter (it sees the un-lowered AST). Handles binding patterns and
     * match patterns; for match patterns, literal sub-nodes are formatted via
     * the existing literal/expression code paths.
     */
    protected formatPattern(pattern: BindingPattern | MatchPattern): string;
    private formatObjectPattern;
    private formatArrayPattern;
    protected generateLiteral(literal: Literal): string;
    private generateStringLiteral;
    private generateMultiLineStringLiteral;
    protected processFunctionDefinition(node: FunctionDefinition): string;
    protected processFunctionCall(node: FunctionCall): string;
    protected renderArgs(args: FunctionCall["arguments"], block?: BlockArgument): string[];
    protected renderArgList(args: FunctionCall["arguments"], block?: BlockArgument): string;
    protected generateFunctionCallExpression(node: FunctionCall, context: "valueAccess" | "functionArg" | "topLevelStatement"): string;
    protected processAgencyArray(node: AgencyArray): string;
    protected processAgencyObject(node: AgencyObject): string;
    private addQuotesToKey;
    protected processValueAccess(node: ValueAccess): string;
    protected asyncAwaitPrefix(code: string, async?: boolean): string;
    protected processMatchBlock(node: MatchBlock): string;
    protected processForLoop(node: ForLoop): string;
    protected processWhileLoop(node: WhileLoop): string;
    protected processIfElse(node: IfElse): string;
    protected processReturnStatement(node: ReturnStatement): string;
    protected processGotoStatement(node: GotoStatement): string;
    protected processDebuggerStatement(node: DebuggerStatement): string;
    protected processComment(node: AgencyComment): string;
    protected processMultiLineComment(node: AgencyMultiLineComment): string;
    protected formatDocComment(node: {
        docComment?: AgencyMultiLineComment;
    }): string;
    protected processImportStatement(node: ImportStatement): string;
    protected processImportNameType(node: ImportNameType): string;
    protected processImportNodeStatement(node: ImportNodeStatement): string;
    protected processExportFromStatement(node: ExportFromStatement): string;
    private sortAndRenderImports;
    protected processGraphNode(node: GraphNodeDefinition): string;
    protected processNewExpression(node: NewExpression): string;
    protected processTool(node: FunctionDefinition): string;
    protected processNewLine(_node: NewLine): string;
    protected renderBody(body: AgencyNode[]): string;
    protected processMessageThread(node: MessageThread): string;
    protected processParallelBlock(node: ParallelBlock): string;
    protected processSeqBlock(node: SeqBlock): string;
    protected processHandleBlock(node: HandleBlock): string;
    protected processSkill(node: Skill): string;
    protected processBinOpExpression(node: BinOpExpression, assigned?: boolean): string;
    private flattenPipeChain;
    protected processAccessChainElement(node: AccessChainElement): string;
    protected formatTag(tag: Tag): string;
    protected formatAttachedTags(node: {
        tags?: Tag[];
    }): string;
    protected processKeyword(node: Keyword): string;
}
export declare function generateAgency(program: AgencyProgram, opts?: {
    preserveOrder?: boolean;
}): string;
