import SwiftUI

// MARK: - Glass Modifier
//
// Uses TelegramGlass* UIViewRepresentable for ALL iOS versions.
// TelegramGlassUIView supports iOS 26 natively (UIGlassEffect) and has
// isUserInteractionEnabled = false, guaranteeing touches pass through.
// SwiftUI .glassEffect() modifier creates UIKit containers that intercept
// taps even with .allowsHitTesting(false).

struct GlassModifier: ViewModifier {
    let cornerRadius: CGFloat

    func body(content: Content) -> some View {
        content
            .background {
                TelegramGlassRoundedRect(cornerRadius: cornerRadius)
            }
    }
}

// MARK: - View Extension

extension View {
    /// Glass background (native on iOS 26+, blur on older).
    func glass(cornerRadius: CGFloat = 24) -> some View {
        modifier(GlassModifier(cornerRadius: cornerRadius))
    }

    /// Glass capsule — convenience for pill-shaped elements.
    func glassCapsule() -> some View {
        background {
            TelegramGlassCapsule()
        }
    }

    /// Glass circle — convenience for circular buttons.
    func glassCircle() -> some View {
        background {
            TelegramGlassCircle()
        }
    }
}
