/**
 * @license
 * Copyright 2025 Steven Roussey <sroussey@gmail.com>
 * SPDX-License-Identifier: Apache-2.0
 */
import type { DataPortSchema } from "@workglow/util/schema";
import { DataPortSchemaNonBoolean, TypedArray, VectorFromSchema } from "@workglow/util/schema";
import { GraphAsTask, GraphAsTaskConfig, GraphAsTaskRunner, GraphResultArray, JsonTaskItem, TaskGraphItemJson, TaskInput, TaskOutput } from "@workglow/task-graph";
import type { TaskRunContext } from "@workglow/task-graph";
export declare function TypeReplicateArray<const T extends DataPortSchemaNonBoolean>(type: T, annotations?: Record<string, unknown>): DataPortSchemaNonBoolean;
/**
 * Removes array types from a union, leaving only non-array types.
 * For example, `string | string[]` becomes `string`.
 * Used to extract the single-value type from schemas with x-replicate annotation.
 * Uses distributive conditional types to filter out arrays from unions.
 * Checks for both array types and types with numeric index signatures (FromSchema array output).
 * Preserves Vector types like Float64Array which also have numeric indices.
 */
type UnwrapArrayUnion<T> = T extends readonly any[] ? T extends TypedArray ? T : never : number extends keyof T ? "push" extends keyof T ? never : T : T;
/**
 * Transforms a schema by removing array variants from properties marked with x-replicate.
 * Properties with x-replicate use {@link TypeReplicateArray} which creates a union of
 * `T | T[]`, and this type extracts just `T`.
 */
export type DeReplicateFromSchema<S extends {
    properties: Record<string, any>;
}> = {
    [K in keyof S["properties"]]: S["properties"][K] extends {
        "x-replicate": true;
    } ? UnwrapArrayUnion<VectorFromSchema<S["properties"][K]>> : VectorFromSchema<S["properties"][K]>;
};
/**
 * ArrayTask is a compound task that either:
 * 1. Executes directly if all inputs are non-arrays
 * 2. Creates a subGraph with one task instance per array element if any input is an array
 * 3. Creates all combinations if multiple inputs are arrays
 */
export declare abstract class ArrayTask<Input extends TaskInput = TaskInput, Output extends TaskOutput = TaskOutput, Config extends GraphAsTaskConfig<Input> = GraphAsTaskConfig<Input>> extends GraphAsTask<Input, Output, Config> {
    /**
     * The type identifier for this task class
     */
    static type: string;
    /**
     * Make this task have results that look like an array
     */
    static readonly compoundMerge: "PROPERTY_ARRAY";
    /**
     * Gets input schema for this task from the static inputSchema property, which is user defined (reverts GraphAsTask's override)
     */
    inputSchema(): DataPortSchema;
    /**
     * Gets output schema for this task from the static outputSchema property, which is user defined (reverts GraphAsTask's override)
     */
    outputSchema(): DataPortSchema;
    /**
     * Merges the preview results into the output
     * @param input The input to the task
     * @param output The output of the task
     * @returns The merged output
     */
    executeMerge(_input: Input, output: Output): Output;
    /**
     * Regenerates the task subgraph based on input arrays
     */
    regenerateGraph(): void;
    /**
     * Generates all possible combinations of array inputs
     * @param input Input object containing arrays
     * @param inputMakeArray Keys of properties to generate combinations for
     * @returns Array of input objects with all possible combinations
     */
    protected generateCombinations(input: Input, inputMakeArray: Array<keyof Input>): Input[];
    toJSON(): TaskGraphItemJson;
    toDependencyJSON(): JsonTaskItem;
    /**
     * Create a custom runner for ArrayTask that overrides input passing behavior
     * as inputs were already distributed to child tasks during graph regeneration
     */
    _runner: ArrayTaskRunner<Input, Output, Config>;
    /**
     * Task runner for handling the task execution
     */
    get runner(): ArrayTaskRunner<Input, Output, Config>;
}
/**
 * Custom runner for ArrayTask that passes empty input to child tasks.
 * ArrayTask child tasks get their input values from their defaults (set during task creation),
 * not from the parent task's input.
 */
declare class ArrayTaskRunner<Input extends TaskInput = TaskInput, Output extends TaskOutput = TaskOutput, Config extends GraphAsTaskConfig<Input> = GraphAsTaskConfig<Input>> extends GraphAsTaskRunner<Input, Output, Config> {
    task: ArrayTask<Input, Output, Config>;
    /**
     * Override to pass empty input to subgraph.
     * Child tasks will use their defaults instead of parent input.
     */
    protected executeTaskChildren(_input: Input): Promise<GraphResultArray<Output>>;
    /**
     * Override to pass empty input to subgraph for preview execution.
     * Child tasks will use their defaults instead of parent input.
     */
    protected executeTaskChildrenPreview(): Promise<GraphResultArray<Output>>;
    executeTaskPreview(input: Input, ctx: TaskRunContext): Promise<Output | undefined>;
    executeTask(input: Input, ctx: TaskRunContext): Promise<Output>;
}
export {};
//# sourceMappingURL=ArrayTask.d.ts.map