import Foundation
import SFSafeSymbols

struct SkillsSet: Identifiable {

    let systemSymbol: SFSymbol

    let entries: [String]

    var id: String {
        entries.joined()
    }
}

extension SkillsSet: Decodable {

    private enum CodingKeys: String, CodingKey {
        case systemSymbol
        case entries
    }

    init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        let rawSymbol = try container.decode(String.self, forKey: .systemSymbol)
        self.systemSymbol = .init(rawValue: rawSymbol)
        self.entries = try container.decode([String].self, forKey: .entries)
    }
}

extension SkillsSet: Encodable {
    func encode(to encoder: Encoder) throws {
        var container = encoder.container(keyedBy: CodingKeys.self)
        try container.encode(systemSymbol.rawValue, forKey: .systemSymbol)
        try container.encode(entries, forKey: .entries)
    }
}
