






#import "BigAlertView.h"
#import "CloudyPrice.h"
#import "RingMiterManager.h"
#import "Masonry.h"

#define mildDry(saw) __weak typeof(saw) weak##saw = saw;
#define followCap(saw) __strong typeof(saw) saw = weak##saw;

@interface BigAlertView()

@property (nonatomic, strong) UIView *whoMaxLeftBendView;
@property (nonatomic, copy) SlavicMakerChlorideBasalStringGolf completion;
@property (nonatomic, strong) UIStackView *locallyFiberView;

@end

@implementation BigAlertView

- (void)dealloc {
    
}

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

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

+ (void)domainPauseTipAllTenDown:(NSString *)title
                        message:(NSString *)message
                   youArmourAir:(NSArray<NSString *> *)youArmourAir
                     completion:(SlavicMakerChlorideBasalStringGolf)completion {
    
    BigAlertView *exist = [[BigAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          youArmourAir:youArmourAir
                                            completion:completion];
    
    
    [RingMiterManager.shared directlyBarriersAdjustingDerivedGramRequiringView:exist];
    
    
    exist.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        exist.alpha = 1.0;
    }];
}

+ (void)domainPauseTipAllTenDown:(NSString *)title message:(NSString *)message completion:(SlavicMakerChlorideBasalStringGolf)completion {
    [self domainPauseTipAllTenDown:title message:message youArmourAir:@[CloudyPrice.presentedIrish.autoPut] completion:completion];
}

@end
