import SwiftUI

extension View {
    func a11yHeader(_ label: String) -> some View {
        self.accessibilityLabel(label)
            .accessibilityAddTraits(.isHeader)
    }

    func a11yHeader() -> some View {
        self.accessibilityAddTraits(.isHeader)
    }

    func a11yDecorative() -> some View {
        self.accessibilityHidden(true)
    }

    func a11yButton(_ label: String, hint: String? = nil) -> some View {
        let view = self.accessibilityLabel(label)
            .accessibilityAddTraits(.isButton)
        if let hint = hint {
            return AnyView(view.accessibilityHint(hint))
        }
        return AnyView(view)
    }

    func a11yImage(_ description: String) -> some View {
        self.accessibilityLabel(description)
            .accessibilityAddTraits(.isImage)
    }

    func a11yCard(label: String) -> some View {
        self.accessibilityElement(children: .combine)
            .accessibilityLabel(label)
    }

    func a11yStatValue(_ value: String, label: String) -> some View {
        self.accessibilityElement(children: .combine)
            .accessibilityLabel(A11y.Common.stat(value: value, label: label))
    }
}
