






#import "AirAlertView.h"
#import "SafeWaxSort.h"
#import "UseKazakhManager.h"
#import "Masonry.h"

#define addPing(odd) __weak typeof(odd) weak##odd = odd;
#define manDecode(odd) __strong typeof(odd) odd = weak##odd;

@interface AirAlertView()

@property (nonatomic, strong) UIView *pintOldOutLateView;
@property (nonatomic, copy) DrivenRepliesListenerGradeArgumentCenters completion;
@property (nonatomic, strong) UIStackView *cupOurHourlyView;

@end

@implementation AirAlertView

- (void)dealloc {
    
}

- (instancetype)initWithFrame:(CGRect)frame
                          title:(NSString *)title
                        message:(NSString *)message
                   useFeatCurve:(NSArray<NSString *> *)useFeatCurve
                     completion:(DrivenRepliesListenerGradeArgumentCenters)completion {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        self.completion = completion;
        
        
        self.pintOldOutLateView = [[UIView alloc] init];
        self.pintOldOutLateView.backgroundColor = [SafeWaxSort teluguDidColor];
        self.pintOldOutLateView.layer.cornerRadius = SafeWaxSort.sinLaunchCut.mergeBarrier;
        self.pintOldOutLateView.clipsToBounds = YES;
        self.pintOldOutLateView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:self.pintOldOutLateView];
        
        
        [NSLayoutConstraint activateConstraints:@[
            [self.pintOldOutLateView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
            [self.pintOldOutLateView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
            [self.pintOldOutLateView.widthAnchor constraintEqualToConstant:270]
        ]];
        
        
        UIView *holdWillView = nil;
        CGFloat romanStableConstantsLeftProfile = 20;
        
        
        if (title.length > 0) {
            UILabel *titleLabel = [[UILabel alloc] init];
            titleLabel.text = title;
            titleLabel.textColor = UIColor.whiteColor;
            titleLabel.font = [UIFont boldSystemFontOfSize:18];
            titleLabel.textAlignment = NSTextAlignmentCenter;
            titleLabel.numberOfLines = 0;
            titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.pintOldOutLateView addSubview:titleLabel];
            
            [NSLayoutConstraint activateConstraints:@[
                [titleLabel.topAnchor constraintEqualToAnchor:self.pintOldOutLateView.topAnchor constant:romanStableConstantsLeftProfile],
                [titleLabel.leadingAnchor constraintEqualToAnchor:self.pintOldOutLateView.leadingAnchor constant:16],
                [titleLabel.trailingAnchor constraintEqualToAnchor:self.pintOldOutLateView.trailingAnchor constant:-16]
            ]];
            
            holdWillView = titleLabel;
        }
        
        
        if (message.length > 0) {
            UILabel *loadYetLabel = [[UILabel alloc] init];
            loadYetLabel.text = message;
            loadYetLabel.textColor = UIColor.whiteColor;
            loadYetLabel.font = [UIFont systemFontOfSize:15];
            loadYetLabel.textAlignment = NSTextAlignmentCenter;
            loadYetLabel.numberOfLines = 0;
            loadYetLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.pintOldOutLateView addSubview:loadYetLabel];
            
            NSLayoutYAxisAnchor *topAnchor = holdWillView ? holdWillView.bottomAnchor : self.pintOldOutLateView.topAnchor;
            CGFloat boxMostTop = holdWillView ? 10 : romanStableConstantsLeftProfile;
            [NSLayoutConstraint activateConstraints:@[
                [loadYetLabel.topAnchor constraintEqualToAnchor:topAnchor constant:boxMostTop],
                [loadYetLabel.leadingAnchor constraintEqualToAnchor:self.pintOldOutLateView.leadingAnchor constant:16],
                [loadYetLabel.trailingAnchor constraintEqualToAnchor:self.pintOldOutLateView.trailingAnchor constant:-16]
            ]];
            holdWillView = loadYetLabel;
        }
        
        
        self.cupOurHourlyView = [[UIStackView alloc] init];
        self.cupOurHourlyView.axis = UILayoutConstraintAxisVertical;
        self.cupOurHourlyView.spacing = 1;  
        self.cupOurHourlyView.distribution = UIStackViewDistributionFillEqually;
        self.cupOurHourlyView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.pintOldOutLateView addSubview:self.cupOurHourlyView];
        
        
        NSLayoutYAxisAnchor *accessingLookupConductorMostDietary = holdWillView ? holdWillView.bottomAnchor : self.pintOldOutLateView.topAnchor;
        CGFloat interNetPickInitiatedDetach = holdWillView ? romanStableConstantsLeftProfile : romanStableConstantsLeftProfile;
        
        [NSLayoutConstraint activateConstraints:@[
            [self.cupOurHourlyView.topAnchor constraintEqualToAnchor:accessingLookupConductorMostDietary constant:interNetPickInitiatedDetach],
            [self.cupOurHourlyView.leadingAnchor constraintEqualToAnchor:self.pintOldOutLateView.leadingAnchor],
            [self.cupOurHourlyView.trailingAnchor constraintEqualToAnchor:self.pintOldOutLateView.trailingAnchor],
            [self.cupOurHourlyView.bottomAnchor constraintEqualToAnchor:self.pintOldOutLateView.bottomAnchor]
        ]];
        
        
       
       if (useFeatCurve.count == 2) {
           
           self.cupOurHourlyView = [[UIStackView alloc] init];
           self.cupOurHourlyView.axis = UILayoutConstraintAxisHorizontal;
           self.cupOurHourlyView.distribution = UIStackViewDistributionFillEqually;
           self.cupOurHourlyView.spacing = 1;  
           self.cupOurHourlyView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.pintOldOutLateView addSubview:self.cupOurHourlyView];
           
           NSLayoutYAxisAnchor *accessingLookupConductorMostDietary = holdWillView ? holdWillView.bottomAnchor : self.pintOldOutLateView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.cupOurHourlyView.topAnchor constraintEqualToAnchor:accessingLookupConductorMostDietary constant:romanStableConstantsLeftProfile],
               [self.cupOurHourlyView.leadingAnchor constraintEqualToAnchor:self.pintOldOutLateView.leadingAnchor],
               [self.cupOurHourlyView.trailingAnchor constraintEqualToAnchor:self.pintOldOutLateView.trailingAnchor],
               [self.cupOurHourlyView.bottomAnchor constraintEqualToAnchor:self.pintOldOutLateView.bottomAnchor]
           ]];
           
           
           for (NSInteger i = 0; i < useFeatCurve.count; i++) {
               NSString *unlikely = useFeatCurve[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:unlikely forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[SafeWaxSort teluguDidColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(safeExpected:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.cupOurHourlyView addArrangedSubview:button];
           }
       } else {
           
           self.cupOurHourlyView = [[UIStackView alloc] init];
           self.cupOurHourlyView.axis = UILayoutConstraintAxisVertical;
           self.cupOurHourlyView.spacing = 1;
           self.cupOurHourlyView.distribution = UIStackViewDistributionFillEqually;
           self.cupOurHourlyView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.pintOldOutLateView addSubview:self.cupOurHourlyView];
           
           NSLayoutYAxisAnchor *accessingLookupConductorMostDietary = holdWillView ? holdWillView.bottomAnchor : self.pintOldOutLateView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.cupOurHourlyView.topAnchor constraintEqualToAnchor:accessingLookupConductorMostDietary constant:romanStableConstantsLeftProfile],
               [self.cupOurHourlyView.leadingAnchor constraintEqualToAnchor:self.pintOldOutLateView.leadingAnchor],
               [self.cupOurHourlyView.trailingAnchor constraintEqualToAnchor:self.pintOldOutLateView.trailingAnchor],
               [self.cupOurHourlyView.bottomAnchor constraintEqualToAnchor:self.pintOldOutLateView.bottomAnchor]
           ]];
           
           for (NSInteger i = 0; i < useFeatCurve.count; i++) {
               NSString *unlikely = useFeatCurve[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:unlikely forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[SafeWaxSort teluguDidColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(safeExpected:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.cupOurHourlyView addArrangedSubview:button];
           }
       }
    }
    return self;
}

- (void)safeExpected:(UIButton *)sender {
    
    [UIView animateWithDuration:0.25 animations:^{
        self.alpha = 0;
    } completion:^(BOOL finished) {
        [UseKazakhManager.shared invisibleEndWindow];
        
        if (self.completion) {
            self.completion(sender.tag);
        }
    }];
}

+ (void)baseManualDecodeIndicesModifiersShowers:(NSString *)title
                        message:(NSString *)message
                   useFeatCurve:(NSArray<NSString *> *)useFeatCurve
                     completion:(DrivenRepliesListenerGradeArgumentCenters)completion {
    
    AirAlertView *speak = [[AirAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          useFeatCurve:useFeatCurve
                                            completion:completion];
    
    
    [UseKazakhManager.shared checkerCriteriaReduceAspectLaotianCapturingView:speak];
    
    
    speak.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        speak.alpha = 1.0;
    }];
}

+ (void)baseManualDecodeIndicesModifiersShowers:(NSString *)title message:(NSString *)message completion:(DrivenRepliesListenerGradeArgumentCenters)completion {
    [self baseManualDecodeIndicesModifiersShowers:title message:message useFeatCurve:@[SafeWaxSort.oldBothLogStop.sendLaw] completion:completion];
}

@end
