import { IMarkdownString } from '../../../../base/common/htmlContent.js';
import { URI, UriComponents } from '../../../../base/common/uri.js';
import { Position, IPosition } from '../../../../editor/common/core/position.js';
import { Range, IRange } from '../../../../editor/common/core/range.js';

declare const enum TestResultState {
    Unset = 0,
    Queued = 1,
    Running = 2,
    Passed = 3,
    Failed = 4,
    Skipped = 5,
    Errored = 6
}
declare const enum TestRunProfileBitset {
    Run = 2,
    Debug = 4,
    Coverage = 8,
    HasNonDefaultProfile = 16,
    HasConfigurable = 32,
    SupportsContinuousRun = 64
}
/**
 * A fully-resolved request to run tests, passsed between the main thread
 * and extension host.
 */
interface ResolvedTestRunRequest {
    group: TestRunProfileBitset;
    targets: {
        testIds: string[];
        controllerId: string;
        profileId: number;
    }[];
    exclude?: string[];
    /** Whether this is a continuous test run */
    continuous?: boolean;
    /** Whether this was trigged by a user action in UI. Default=true */
    preserveFocus?: boolean;
}
/** Subset of the IUriIdentityService */
interface ITestUriCanonicalizer {
    /** @link import('vs/platform/uriIdentity/common/uriIdentity').IUriIdentityService */
    asCanonicalUri(uri: URI): URI;
}
/**
 * Location with a fully-instantiated Range and URI.
 */
interface IRichLocation {
    range: Range;
    uri: URI;
}
declare namespace IRichLocation {
    interface Serialize {
        range: IRange;
        uri: UriComponents;
    }
    const serialize: (location: Readonly<IRichLocation>) => Serialize;
    const deserialize: (uriIdentity: ITestUriCanonicalizer, location: Serialize) => IRichLocation;
}
declare const enum TestMessageType {
    Error = 0,
    Output = 1
}
interface ITestErrorMessage {
    message: string | IMarkdownString;
    type: TestMessageType.Error;
    expected: string | undefined;
    actual: string | undefined;
    contextValue: string | undefined;
    location: IRichLocation | undefined;
}
declare namespace ITestErrorMessage {
    interface Serialized {
        message: string | IMarkdownString;
        type: TestMessageType.Error;
        expected: string | undefined;
        actual: string | undefined;
        contextValue: string | undefined;
        location: IRichLocation.Serialize | undefined;
    }
    const serialize: (message: Readonly<ITestErrorMessage>) => Serialized;
    const deserialize: (uriIdentity: ITestUriCanonicalizer, message: Serialized) => ITestErrorMessage;
}
interface ITestOutputMessage {
    message: string;
    type: TestMessageType.Output;
    offset: number;
    length: number;
    marker?: number;
    location: IRichLocation | undefined;
}
declare namespace ITestOutputMessage {
    interface Serialized {
        message: string;
        offset: number;
        length: number;
        type: TestMessageType.Output;
        location: IRichLocation.Serialize | undefined;
    }
    const serialize: (message: Readonly<ITestOutputMessage>) => Serialized;
    const deserialize: (uriIdentity: ITestUriCanonicalizer, message: Serialized) => ITestOutputMessage;
}
type ITestMessage = ITestErrorMessage | ITestOutputMessage;
declare namespace ITestMessage {
    type Serialized = ITestErrorMessage.Serialized | ITestOutputMessage.Serialized;
    const serialize: (message: Readonly<ITestMessage>) => Serialized;
    const deserialize: (uriIdentity: ITestUriCanonicalizer, message: Serialized) => ITestMessage;
}
interface ITestTaskState {
    state: TestResultState;
    duration: number | undefined;
    messages: ITestMessage[];
}
declare namespace ITestTaskState {
    interface Serialized {
        state: TestResultState;
        duration: number | undefined;
        messages: ITestMessage.Serialized[];
    }
    const serializeWithoutMessages: (state: ITestTaskState) => Serialized;
    const serialize: (state: Readonly<ITestTaskState>) => Serialized;
    const deserialize: (uriIdentity: ITestUriCanonicalizer, state: Serialized) => ITestTaskState;
}
interface ITestRunTask {
    id: string;
    name: string | undefined;
    running: boolean;
}
/**
 * The TestItem from .d.ts, as a plain object without children.
 */
interface ITestItem {
    /** ID of the test given by the test controller */
    extId: string;
    label: string;
    tags: string[];
    busy: boolean;
    children?: never;
    uri: URI | undefined;
    range: Range | null;
    description: string | null;
    error: string | IMarkdownString | null;
    sortText: string | null;
}
declare namespace ITestItem {
    interface Serialized {
        extId: string;
        label: string;
        tags: string[];
        busy: boolean;
        children?: never;
        uri: UriComponents | undefined;
        range: IRange | null;
        description: string | null;
        error: string | IMarkdownString | null;
        sortText: string | null;
    }
    const serialize: (item: Readonly<ITestItem>) => Serialized;
    const deserialize: (uriIdentity: ITestUriCanonicalizer, serialized: Serialized) => ITestItem;
}
declare const enum TestItemExpandState {
    NotExpandable = 0,
    Expandable = 1,
    BusyExpanding = 2,
    Expanded = 3
}
/**
 * TestItem-like shape, but with an ID and children as strings.
 */
interface InternalTestItem {
    /** Controller ID from whence this test came */
    controllerId: string;
    /** Expandability state */
    expand: TestItemExpandState;
    /** Raw test item properties */
    item: ITestItem;
}
declare namespace InternalTestItem {
    interface Serialized {
        expand: TestItemExpandState;
        item: ITestItem.Serialized;
    }
    const serialize: (item: Readonly<InternalTestItem>) => Serialized;
    const deserialize: (uriIdentity: ITestUriCanonicalizer, serialized: Serialized) => InternalTestItem;
}
/**
 * Test result item used in the main thread.
 */
interface TestResultItem extends InternalTestItem {
    /** State of this test in various tasks */
    tasks: ITestTaskState[];
    /** State of this test as a computation of its tasks */
    ownComputedState: TestResultState;
    /** Computed state based on children */
    computedState: TestResultState;
    /** Max duration of the item's tasks (if run directly) */
    ownDuration?: number;
    /** Whether this test item is outdated */
    retired?: boolean;
}
declare namespace TestResultItem {
    /**
     * Serialized version of the TestResultItem. Note that 'retired' is not
     * included since all hydrated items are automatically retired.
     */
    interface Serialized extends InternalTestItem.Serialized {
        tasks: ITestTaskState.Serialized[];
        ownComputedState: TestResultState;
        computedState: TestResultState;
    }
    const serializeWithoutMessages: (original: TestResultItem) => Serialized;
    const serialize: (original: Readonly<TestResultItem>) => Serialized;
    const deserialize: (uriIdentity: ITestUriCanonicalizer, serialized: Serialized) => TestResultItem;
}
interface ISerializedTestResults {
    /** ID of these test results */
    id: string;
    /** Time the results were compelted */
    completedAt: number;
    /** Subset of test result items */
    items: TestResultItem.Serialized[];
    /** Tasks involved in the run. */
    tasks: {
        id: string;
        name: string | undefined;
    }[];
    /** Human-readable name of the test run. */
    name: string;
    /** Test trigger informaton */
    request: ResolvedTestRunRequest;
}
interface ICoverageCount {
    covered: number;
    total: number;
}
declare namespace ICoverageCount {
    const empty: () => ICoverageCount;
    const sum: (target: ICoverageCount, src: Readonly<ICoverageCount>) => void;
}
interface IFileCoverage {
    id: string;
    uri: URI;
    testIds?: string[];
    statement: ICoverageCount;
    branch?: ICoverageCount;
    declaration?: ICoverageCount;
}
declare namespace IFileCoverage {
    interface Serialized {
        id: string;
        uri: UriComponents;
        testIds: string[] | undefined;
        statement: ICoverageCount;
        branch?: ICoverageCount;
        declaration?: ICoverageCount;
    }
    const serialize: (original: Readonly<IFileCoverage>) => Serialized;
    const deserialize: (uriIdentity: ITestUriCanonicalizer, serialized: Serialized) => IFileCoverage;
    const empty: (id: string, uri: URI) => IFileCoverage;
}
declare const enum DetailType {
    Declaration = 0,
    Statement = 1,
    Branch = 2
}
type CoverageDetails = IDeclarationCoverage | IStatementCoverage;
declare namespace CoverageDetails {
    type Serialized = IDeclarationCoverage.Serialized | IStatementCoverage.Serialized;
    const serialize: (original: Readonly<CoverageDetails>) => Serialized;
    const deserialize: (serialized: Serialized) => CoverageDetails;
}
interface IBranchCoverage {
    count: number | boolean;
    label?: string;
    location?: Range | Position;
}
declare namespace IBranchCoverage {
    interface Serialized {
        count: number | boolean;
        label?: string;
        location?: IRange | IPosition;
    }
    const serialize: (original: IBranchCoverage) => Serialized;
    const deserialize: (original: Serialized) => IBranchCoverage;
}
interface IDeclarationCoverage {
    type: DetailType.Declaration;
    name: string;
    count: number | boolean;
    location: Range | Position;
}
declare namespace IDeclarationCoverage {
    interface Serialized {
        type: DetailType.Declaration;
        name: string;
        count: number | boolean;
        location: IRange | IPosition;
    }
    const serialize: (original: IDeclarationCoverage) => Serialized;
    const deserialize: (original: Serialized) => IDeclarationCoverage;
}
interface IStatementCoverage {
    type: DetailType.Statement;
    count: number | boolean;
    location: Range | Position;
    branches?: IBranchCoverage[];
}
declare namespace IStatementCoverage {
    interface Serialized {
        type: DetailType.Statement;
        count: number | boolean;
        location: IRange | IPosition;
        branches?: IBranchCoverage.Serialized[];
    }
    const serialize: (original: Readonly<IStatementCoverage>) => Serialized;
    const deserialize: (serialized: Serialized) => IStatementCoverage;
}

export { CoverageDetails, DetailType, IBranchCoverage, ICoverageCount, IDeclarationCoverage, IFileCoverage, IRichLocation, type ISerializedTestResults, IStatementCoverage, ITestErrorMessage, ITestItem, ITestMessage, ITestOutputMessage, type ITestRunTask, ITestTaskState, type ITestUriCanonicalizer, InternalTestItem, type ResolvedTestRunRequest, TestItemExpandState, TestMessageType, TestResultItem, TestResultState, TestRunProfileBitset };
