import Foundation

final class PathSettings: ObservableObject {

    @Published
    var assetsOutputFolderPath: String

    @Published
    var pagesOutputFolderPath: String

    @Published
    var imagesOutputFolderPath: String

    @Published
    var filesOutputFolderPath: String

    @Published
    var videosOutputFolderPath: String

    @Published
    var audioOutputFolderPath: String

    @Published
    var tagsOutputFolderPath: String

    init(assetsOutputFolderPath: String,
         pagesOutputFolderPath: String,
         imagesOutputFolderPath: String,
         filesOutputFolderPath: String,
         videosOutputFolderPath: String,
         audioOutputFolderPath: String,
         tagsOutputFolderPath: String) {
        self.assetsOutputFolderPath = assetsOutputFolderPath
        self.pagesOutputFolderPath = pagesOutputFolderPath
        self.imagesOutputFolderPath = imagesOutputFolderPath
        self.filesOutputFolderPath = filesOutputFolderPath
        self.videosOutputFolderPath = videosOutputFolderPath
        self.audioOutputFolderPath = audioOutputFolderPath
        self.tagsOutputFolderPath = tagsOutputFolderPath
    }
}

extension PathSettings {

    convenience init(data: Data) {
        self.init(
            assetsOutputFolderPath: data.assetsOutputFolderPath,
            pagesOutputFolderPath: data.pagesOutputFolderPath,
            imagesOutputFolderPath: data.imagesOutputFolderPath,
            filesOutputFolderPath: data.filesOutputFolderPath,
            videosOutputFolderPath: data.videosOutputFolderPath,
            audioOutputFolderPath: data.audioOutputFolderPath,
            tagsOutputFolderPath: data.tagsOutputFolderPath)
    }

    var data: Data {
        .init(
            assetsOutputFolderPath: assetsOutputFolderPath,
            pagesOutputFolderPath: pagesOutputFolderPath,
            imagesOutputFolderPath: imagesOutputFolderPath,
            filesOutputFolderPath: filesOutputFolderPath,
            videosOutputFolderPath: videosOutputFolderPath,
            audioOutputFolderPath: audioOutputFolderPath,
            tagsOutputFolderPath: tagsOutputFolderPath)
    }

    struct Data: Codable, Equatable {
        let assetsOutputFolderPath: String
        let pagesOutputFolderPath: String
        let imagesOutputFolderPath: String
        let filesOutputFolderPath: String
        let videosOutputFolderPath: String
        let audioOutputFolderPath: String
        let tagsOutputFolderPath: String
    }
}
