






#import "ItsAlertView.h"
#import "FrictionShe.h"
#import "OpaqueKeyManager.h"
#import "Masonry.h"

#define canRace(fat) __weak typeof(fat) weak##fat = fat;
#define bayerMake(fat) __strong typeof(fat) fat = weak##fat;

@interface ItsAlertView()

@property (nonatomic, strong) UIView *tagMileMaxNearView;
@property (nonatomic, copy) OffTerahertzMotionHairLanguageDiscovery completion;
@property (nonatomic, strong) UIStackView *dublinLinearView;

@end

@implementation ItsAlertView

- (void)dealloc {
    
}

- (instancetype)initWithFrame:(CGRect)frame
                          title:(NSString *)title
                        message:(NSString *)message
                   farsiOperate:(NSArray<NSString *> *)farsiOperate
                     completion:(OffTerahertzMotionHairLanguageDiscovery)completion {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        self.completion = completion;
        
        
        self.tagMileMaxNearView = [[UIView alloc] init];
        self.tagMileMaxNearView.backgroundColor = [FrictionShe collectorColor];
        self.tagMileMaxNearView.layer.cornerRadius = 8.0;
        self.tagMileMaxNearView.clipsToBounds = YES;
        self.tagMileMaxNearView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:self.tagMileMaxNearView];
        
        
        [NSLayoutConstraint activateConstraints:@[
            [self.tagMileMaxNearView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
            [self.tagMileMaxNearView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
            [self.tagMileMaxNearView.widthAnchor constraintEqualToConstant:270]
        ]];
        
        
        UIView *rationalView = nil;
        CGFloat malformedClangWinGramBrand = 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.tagMileMaxNearView addSubview:titleLabel];
            
            [NSLayoutConstraint activateConstraints:@[
                [titleLabel.topAnchor constraintEqualToAnchor:self.tagMileMaxNearView.topAnchor constant:malformedClangWinGramBrand],
                [titleLabel.leadingAnchor constraintEqualToAnchor:self.tagMileMaxNearView.leadingAnchor constant:16],
                [titleLabel.trailingAnchor constraintEqualToAnchor:self.tagMileMaxNearView.trailingAnchor constant:-16]
            ]];
            
            rationalView = titleLabel;
        }
        
        
        if (message.length > 0) {
            UILabel *askPassLabel = [[UILabel alloc] init];
            askPassLabel.text = message;
            askPassLabel.textColor = UIColor.whiteColor;
            askPassLabel.font = [UIFont systemFontOfSize:15];
            askPassLabel.textAlignment = NSTextAlignmentCenter;
            askPassLabel.numberOfLines = 0;
            askPassLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.tagMileMaxNearView addSubview:askPassLabel];
            
            NSLayoutYAxisAnchor *topAnchor = rationalView ? rationalView.bottomAnchor : self.tagMileMaxNearView.topAnchor;
            CGFloat friendsPan = rationalView ? 10 : malformedClangWinGramBrand;
            [NSLayoutConstraint activateConstraints:@[
                [askPassLabel.topAnchor constraintEqualToAnchor:topAnchor constant:friendsPan],
                [askPassLabel.leadingAnchor constraintEqualToAnchor:self.tagMileMaxNearView.leadingAnchor constant:16],
                [askPassLabel.trailingAnchor constraintEqualToAnchor:self.tagMileMaxNearView.trailingAnchor constant:-16]
            ]];
            rationalView = askPassLabel;
        }
        
        
        self.dublinLinearView = [[UIStackView alloc] init];
        self.dublinLinearView.axis = UILayoutConstraintAxisVertical;
        self.dublinLinearView.spacing = 1;  
        self.dublinLinearView.distribution = UIStackViewDistributionFillEqually;
        self.dublinLinearView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.tagMileMaxNearView addSubview:self.dublinLinearView];
        
        
        NSLayoutYAxisAnchor *addressesTertiaryCanonBridgeCat = rationalView ? rationalView.bottomAnchor : self.tagMileMaxNearView.topAnchor;
        CGFloat strongestVeryDrumLargerDesigner = rationalView ? malformedClangWinGramBrand : malformedClangWinGramBrand;
        
        [NSLayoutConstraint activateConstraints:@[
            [self.dublinLinearView.topAnchor constraintEqualToAnchor:addressesTertiaryCanonBridgeCat constant:strongestVeryDrumLargerDesigner],
            [self.dublinLinearView.leadingAnchor constraintEqualToAnchor:self.tagMileMaxNearView.leadingAnchor],
            [self.dublinLinearView.trailingAnchor constraintEqualToAnchor:self.tagMileMaxNearView.trailingAnchor],
            [self.dublinLinearView.bottomAnchor constraintEqualToAnchor:self.tagMileMaxNearView.bottomAnchor]
        ]];
        
        
       
       if (farsiOperate.count == 2) {
           
           self.dublinLinearView = [[UIStackView alloc] init];
           self.dublinLinearView.axis = UILayoutConstraintAxisHorizontal;
           self.dublinLinearView.distribution = UIStackViewDistributionFillEqually;
           self.dublinLinearView.spacing = 1;  
           self.dublinLinearView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.tagMileMaxNearView addSubview:self.dublinLinearView];
           
           NSLayoutYAxisAnchor *addressesTertiaryCanonBridgeCat = rationalView ? rationalView.bottomAnchor : self.tagMileMaxNearView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.dublinLinearView.topAnchor constraintEqualToAnchor:addressesTertiaryCanonBridgeCat constant:malformedClangWinGramBrand],
               [self.dublinLinearView.leadingAnchor constraintEqualToAnchor:self.tagMileMaxNearView.leadingAnchor],
               [self.dublinLinearView.trailingAnchor constraintEqualToAnchor:self.tagMileMaxNearView.trailingAnchor],
               [self.dublinLinearView.bottomAnchor constraintEqualToAnchor:self.tagMileMaxNearView.bottomAnchor]
           ]];
           
           
           for (NSInteger i = 0; i < farsiOperate.count; i++) {
               NSString *featured = farsiOperate[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:featured forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[FrictionShe collectorColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(denyFlushKit:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.dublinLinearView addArrangedSubview:button];
           }
       } else {
           
           self.dublinLinearView = [[UIStackView alloc] init];
           self.dublinLinearView.axis = UILayoutConstraintAxisVertical;
           self.dublinLinearView.spacing = 1;
           self.dublinLinearView.distribution = UIStackViewDistributionFillEqually;
           self.dublinLinearView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.tagMileMaxNearView addSubview:self.dublinLinearView];
           
           NSLayoutYAxisAnchor *addressesTertiaryCanonBridgeCat = rationalView ? rationalView.bottomAnchor : self.tagMileMaxNearView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.dublinLinearView.topAnchor constraintEqualToAnchor:addressesTertiaryCanonBridgeCat constant:malformedClangWinGramBrand],
               [self.dublinLinearView.leadingAnchor constraintEqualToAnchor:self.tagMileMaxNearView.leadingAnchor],
               [self.dublinLinearView.trailingAnchor constraintEqualToAnchor:self.tagMileMaxNearView.trailingAnchor],
               [self.dublinLinearView.bottomAnchor constraintEqualToAnchor:self.tagMileMaxNearView.bottomAnchor]
           ]];
           
           for (NSInteger i = 0; i < farsiOperate.count; i++) {
               NSString *featured = farsiOperate[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:featured forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[FrictionShe collectorColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(denyFlushKit:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.dublinLinearView addArrangedSubview:button];
           }
       }
    }
    return self;
}

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

+ (void)hellmanPrefixedLongBetterNormalTied:(NSString *)title
                        message:(NSString *)message
                   farsiOperate:(NSArray<NSString *> *)farsiOperate
                     completion:(OffTerahertzMotionHairLanguageDiscovery)completion {
    
    ItsAlertView *heart = [[ItsAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          farsiOperate:farsiOperate
                                            completion:completion];
    
    
    [OpaqueKeyManager.shared actualBitMandarinWinCloudyDegradedView:heart];
    
    
    heart.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        heart.alpha = 1.0;
    }];
}

+ (void)hellmanPrefixedLongBetterNormalTied:(NSString *)title message:(NSString *)message completion:(OffTerahertzMotionHairLanguageDiscovery)completion {
    [self hellmanPrefixedLongBetterNormalTied:title message:message farsiOperate:@[FrictionShe.saltBurstFinal.backSob] completion:completion];
}

@end
