import {ComponentExporterImporter, PreloadedDynamicValues} from "../ComponentExporterImporter";
import {TestableData} from "../../store";
import {ExportImportTarget} from "../Exporters";
import {TagsOptions} from "../../cards/Tags";

export class CategoriesExporterImporter implements ComponentExporterImporter<TestableData<TagsOptions>, TestableData<TagsOptions>> {
    type= 'InTags'

    exportData(data: TestableData<TagsOptions>, target: ExportImportTarget): TestableData<TagsOptions> {
        if (target === 'preset') {
            data.options.expectedValues = []
        }

        return data
    }

    tagDynamicValues({
                         options: {
                             expectedValues,
                             excludedSubsetValues
                         }
                     }: TestableData<TagsOptions>, target: ExportImportTarget): PreloadedDynamicValues {
        return {
            category: 'tags',
            values: [...expectedValues, ...(excludedSubsetValues || [])]
        };
    }
}