const path = require('path');

function filename(sequenceOrFilename, extension) {
	if (typeof sequenceOrFilename === "string") {
		const name = sequenceOrFilename;
		return path.basename(name, path.extname(name))+extension;
	} else if (typeof sequenceOrFilename === "object") {
		const sequence = sequenceOrFilename;
		const lineName = sequence?.meta?.lineName;
		const fileName = lineName
			? `${lineName}-NavLog${extension}`
			: `sequence-${sequence?.sequence}${extension}`;
		return fileName;
	} else {
		return "SequenceData"+extension;
	}
}

module.exports = filename;
