import { runPipeline, InterfaceTypes } from 'itk-wasm';
import { getPipelinesBaseUrl } from './pipelines-base-url.js';
import { getPipelineWorkerUrl } from './pipeline-worker-url.js';
async function readImageDicomFileSeriesWorkerFunction(inputImages, singleSortedSeries = false, options = {}) {
    const desiredOutputs = [
        { type: InterfaceTypes.Image },
        { type: InterfaceTypes.JsonCompatible },
    ];
    const inputs = [];
    const args = [];
    // Inputs
    // Outputs
    const outputImageName = '0';
    args.push(outputImageName);
    const sortedFilenamesName = '1';
    args.push(sortedFilenamesName);
    // Options
    args.push('--memory-io');
    args.push('--input-images');
    inputImages.forEach((value) => {
        inputs.push({ type: InterfaceTypes.BinaryFile, data: value });
        args.push(value.path);
    });
    if (typeof singleSortedSeries !== "undefined") {
        singleSortedSeries && args.push('--single-sorted-series');
    }
    const pipelinePath = 'read-image-dicom-file-series';
    const { webWorker: usedWebWorker, returnValue, stderr, outputs } = await runPipeline(pipelinePath, args, desiredOutputs, inputs, { pipelineBaseUrl: getPipelinesBaseUrl(), pipelineWorkerUrl: getPipelineWorkerUrl(), webWorker: options?.webWorker ?? null });
    if (returnValue !== 0) {
        throw new Error(stderr);
    }
    const result = {
        webWorker: usedWebWorker,
        outputImage: outputs[0].data,
        sortedFilenames: outputs[1].data,
    };
    return result;
}
export default readImageDicomFileSeriesWorkerFunction;
//# sourceMappingURL=read-image-dicom-file-series-worker-function.js.map