"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getLoc = getLoc;
exports.createTrixAdapter = createTrixAdapter;
exports.createPerTrackTrixAdapter = createPerTrackTrixAdapter;
exports.getAdapterLocation = getAdapterLocation;
function getLoc(elt) {
    return elt.locationType === 'LocalPathLocation' ? elt.localPath : elt.uri;
}
function createTrixAdapter(id, asm, assemblyNames) {
    return {
        type: 'TrixTextSearchAdapter',
        textSearchAdapterId: id,
        ixFilePath: {
            uri: `trix/${asm}.ix`,
            locationType: 'UriLocation',
        },
        ixxFilePath: {
            uri: `trix/${asm}.ixx`,
            locationType: 'UriLocation',
        },
        metaFilePath: {
            uri: `trix/${asm}_meta.json`,
            locationType: 'UriLocation',
        },
        assemblyNames: assemblyNames || [asm],
    };
}
function createPerTrackTrixAdapter(trackId, assemblyNames) {
    return {
        type: 'TrixTextSearchAdapter',
        textSearchAdapterId: `${trackId}-index`,
        ixFilePath: {
            uri: `trix/${trackId}.ix`,
            locationType: 'UriLocation',
        },
        ixxFilePath: {
            uri: `trix/${trackId}.ixx`,
            locationType: 'UriLocation',
        },
        metaFilePath: {
            uri: `trix/${trackId}_meta.json`,
            locationType: 'UriLocation',
        },
        assemblyNames: assemblyNames,
    };
}
function getAdapterLocation(adapter) {
    const { type } = adapter || {};
    if (type === 'Gff3TabixAdapter') {
        return adapter.gffGzLocation || adapter;
    }
    else if (type === 'Gff3Adapter') {
        return adapter.gffLocation || adapter;
    }
    else if (type === 'VcfAdapter') {
        return adapter.vcfLocation || adapter;
    }
    else if (type === 'VcfTabixAdapter') {
        return adapter.vcfGzLocation || adapter;
    }
    return undefined;
}
