import { z } from 'zod';
export const CodeNodeTypeSchema = z.enum([
    'file',
    'module',
    'function',
    'class',
    'interface',
    'type-alias',
    'enum',
    'variable',
    'parameter',
]);
export const NormalizedSymbolKindSchema = z.enum([
    'file',
    'module',
    'function',
    'method',
    'class',
    'interface',
    'type',
    'enum',
    'variable',
    'parameter',
    'other',
]);
export function toNormalizedSymbolKind(type, containerName) {
    switch (type) {
        case 'file':
            return 'file';
        case 'module':
            return 'module';
        case 'function':
            return containerName ? 'method' : 'function';
        case 'class':
            return 'class';
        case 'interface':
            return 'interface';
        case 'type-alias':
            return 'type';
        case 'enum':
            return 'enum';
        case 'variable':
            return 'variable';
        case 'parameter':
            return 'parameter';
        default:
            return 'other';
    }
}
export const CodeEdgeTypeSchema = z.enum(['contains', 'imports', 'calls', 'inherits', 'implements', 'has_parameter']);
export const ResolutionStatusSchema = z.enum(['resolved', 'ambiguous', 'unresolved']);
export const ImportKindSchema = z.enum(['local', 'external', 'unresolved']);
export const ContentModeSchema = z.enum(['none', 'excerpt', 'full']);
export const CodeCapabilitiesSchema = z.object({
    definitions: z.boolean(),
    imports: z.boolean(),
    calls: z.boolean(),
    inheritance: z.boolean(),
    content: z.boolean(),
});
export const CodeSkippedFileSchema = z.object({
    path: z.string(),
    relativePath: z.string(),
    reason: z.string(),
});
export const ParsedImportBindingSchema = z.object({
    localName: z.string(),
    importedName: z.string().optional(),
    isNamespace: z.boolean().optional(),
    isDefault: z.boolean().optional(),
});
export const ParsedImportSchema = z.object({
    specifier: z.string(),
    line: z.number(),
    kind: ImportKindSchema,
    bindings: z.array(ParsedImportBindingSchema),
    resolvedPath: z.string().optional(),
    isReExport: z.boolean().optional(),
});
export const ParsedSymbolSchema = z.object({
    type: z.enum(['function', 'class', 'interface', 'type-alias', 'enum', 'variable']),
    name: z.string(),
    /** Id of this symbol's graph node; stamped during index assembly. */
    nodeId: z.string().optional(),
    line: z.number(),
    endLine: z.number().optional(),
    startColumn: z.number().optional(),
    endColumn: z.number().optional(),
    containerName: z.string().optional(),
    signature: z.string().optional(),
    exported: z.boolean().optional(),
    fullSignature: z.string().optional(),
    returnType: z.string().optional(),
    jsdoc: z.string().optional(),
    isAsync: z.boolean().optional(),
    isStatic: z.boolean().optional(),
    visibility: z.enum(['public', 'protected', 'private']).optional(),
});
export const ParsedCallSchema = z.object({
    callerName: z.string(),
    callerLine: z.number(),
    callerContainerName: z.string().optional(),
    calleeName: z.string(),
    qualifier: z.string().optional(),
    line: z.number(),
});
export const ParsedInheritanceSchema = z.object({
    className: z.string(),
    classLine: z.number(),
    baseName: z.string(),
    line: z.number(),
    kind: z.enum(['extends', 'implements']).optional(),
});
export const CodeExcerptSchema = z.object({
    content: z.string(),
    startLine: z.number(),
    endLine: z.number(),
    reason: z.string(),
});
export const ParsedFileSchema = z.object({
    path: z.string(),
    relativePath: z.string(),
    moduleName: z.string(),
    language: z.string(),
    content: z.string().optional(),
    lines: z.array(z.string()).optional(),
    excerpt: CodeExcerptSchema.optional(),
    symbols: z.array(ParsedSymbolSchema),
    imports: z.array(ParsedImportSchema),
    calls: z.array(ParsedCallSchema),
    inheritances: z.array(ParsedInheritanceSchema),
});
export const IndexTruncationSchema = z.object({
    reason: z.enum(['maxFiles', 'maxBytes', 'maxFilesAndBytes']),
    keptFiles: z.number(),
    droppedFiles: z.number(),
    totalFiles: z.number(),
    totalBytes: z.number(),
    maxFiles: z.number().optional(),
    maxBytes: z.number().optional(),
});
export const CodeNodeSchema = z.object({
    id: z.string(),
    type: CodeNodeTypeSchema,
    name: z.string(),
    path: z.string(),
    relativePath: z.string().optional(),
    line: z.number().optional(),
    endLine: z.number().optional(),
    startColumn: z.number().optional(),
    endColumn: z.number().optional(),
    language: z.string(),
    moduleName: z.string().optional(),
    containerId: z.string().optional(),
    containerName: z.string().optional(),
    signature: z.string().optional(),
    external: z.boolean().optional(),
});
export const CodeEdgeSchema = z.object({
    id: z.string(),
    type: CodeEdgeTypeSchema,
    from: z.string(),
    to: z.string().optional(),
    fromPath: z.string(),
    toPath: z.string().optional(),
    line: z.number().optional(),
    status: ResolutionStatusSchema,
    targetName: z.string().optional(),
    detail: z.string().optional(),
    specifier: z.string().optional(),
    importKind: ImportKindSchema.optional(),
    candidates: z
        .array(z.object({
        name: z.string(),
        relativePath: z.string().optional(),
        line: z.number().optional(),
    }))
        .optional(),
});
export const CodebaseIndexSchema = z.object({
    repoRoot: z.string(),
    contentMode: ContentModeSchema,
    files: z.array(ParsedFileSchema),
    nodes: z.array(CodeNodeSchema),
    edges: z.array(CodeEdgeSchema),
    capabilities: z.record(z.string(), CodeCapabilitiesSchema),
    skippedFiles: z.array(CodeSkippedFileSchema),
    truncated: IndexTruncationSchema.optional(),
});
export const DirectoryTreeModeSchema = z.enum(['compact', 'verbose', 'map']);
export const DirectoryTreeOptionsSchema = z.object({
    mode: DirectoryTreeModeSchema.optional(),
    maxDepth: z.number().int().nonnegative().optional(),
    maxEntriesPerDir: z.number().int().positive().optional(),
    tokenBudget: z.number().int().positive().optional(),
    byteBudget: z.number().int().positive().optional(),
    focusPath: z.string().optional(),
});
export const DirectoryTreeSymbolSchema = z.object({
    nodeId: z.string().optional(),
    name: z.string(),
    kind: NormalizedSymbolKindSchema,
    signature: z.string(),
    line: z.number().optional(),
    relativePath: z.string(),
});
export const DirectoryTreeEntrySchema = z.object({
    kind: z.enum(['directory', 'file']),
    path: z.string(),
    name: z.string(),
    depth: z.number(),
    fileCount: z.number().optional(),
    language: z.string().optional(),
    score: z.number().optional(),
    normalizedScore: z.number().optional(),
    symbols: z.array(DirectoryTreeSymbolSchema).optional(),
});
export const DirectoryTreeResultSchema = z.object({
    root: z.string(),
    focusPath: z.string().optional(),
    mode: DirectoryTreeModeSchema,
    maxDepth: z.number(),
    maxEntriesPerDir: z.number(),
    tokenBudget: z.number().optional(),
    tokensUsed: z.number(),
    byteBudget: z.number().optional(),
    bytesUsed: z.number(),
    totalFiles: z.number(),
    totalDirectories: z.number(),
    entries: z.array(DirectoryTreeEntrySchema),
    lines: z.array(z.string()),
    truncated: z.boolean(),
    truncatedPaths: z.array(z.string()),
});
export const CodeSearchResultSchema = z.object({
    node: CodeNodeSchema,
    resolution: ResolutionStatusSchema.optional(),
});
export const ContentMatchSchema = z.object({
    path: z.string(),
    relativePath: z.string(),
    language: z.string(),
    line: z.number(),
    snippet: z.string(),
});
export const RelationMatchSchema = z.object({
    from: CodeNodeSchema,
    edge: CodeEdgeSchema,
    to: CodeNodeSchema.optional(),
});
export const DependencyAnalysisSchema = z.object({
    target: z.string(),
    targetFile: CodeNodeSchema.optional(),
    importers: z.array(RelationMatchSchema),
    localImports: z.array(RelationMatchSchema),
    externalImports: z.array(RelationMatchSchema),
    unresolvedImports: z.array(RelationMatchSchema),
});
export const ClassTreeAnalysisSchema = z.object({
    target: CodeNodeSchema,
    parents: z.array(RelationMatchSchema),
    children: z.array(RelationMatchSchema),
    methods: z.array(CodeNodeSchema),
});
export const CallChainSchema = z.object({
    nodes: z.array(CodeNodeSchema),
    edges: z.array(CodeEdgeSchema),
    direction: z.enum(['forward', 'reverse']).optional(),
    status: z.enum(['resolved', 'blocked_ambiguous']).optional(),
    blockedAt: CodeNodeSchema.optional(),
    blockedBy: CodeEdgeSchema.optional(),
});
export const CodeCommandPayloadSchema = z.object({
    repo: z.string(),
    contentMode: ContentModeSchema,
    query: z.record(z.string(), z.unknown()),
    results: z.unknown(),
    stats: z.object({
        filesIndexed: z.number(),
        nodes: z.number(),
        edges: z.number(),
        skippedFiles: z.number(),
    }),
    capabilities: z.record(z.string(), CodeCapabilitiesSchema),
});
//# sourceMappingURL=types.js.map