//
//  CollapseState.swift
//  Pachyderm
//
//  Created by Shadowfacts on 11/24/19.
//  Copyright © 2019 Shadowfacts. All rights reserved.
//

import Foundation

@MainActor
public final class CollapseState: Sendable {
    public var collapsible: Bool?
    public var collapsed: Bool?
    public var statusPropertiesHash: Int?

    public var unknown: Bool {
        collapsible == nil || collapsed == nil
    }
    
    public init(collapsible: Bool?, collapsed: Bool?) {
        self.collapsible = collapsible
        self.collapsed = collapsed
    }
    
    public func copy() -> CollapseState {
        let new = CollapseState(collapsible: self.collapsible, collapsed: self.collapsed)
        new.statusPropertiesHash = self.statusPropertiesHash
        return new
    }
    
    public func hash(into hasher: inout Hasher) {
        hasher.combine(collapsible)
        hasher.combine(collapsed)
    }

    public static var unknown: CollapseState {
        CollapseState(collapsible: nil, collapsed: nil)
    }
}
