






#import "WonAlertView.h"
#import "BinFaxEight.h"
#import "BalticFixManager.h"
#import "Masonry.h"

#define formRow(obj) __weak typeof(obj) weak##obj = obj;
#define restExits(obj) __strong typeof(obj) obj = weak##obj;

@interface WonAlertView()

@property (nonatomic, strong) UIView *askNotBigPowerView;
@property (nonatomic, copy) EditSoftDefineTwoFlowArts completion;
@property (nonatomic, strong) UIStackView *tenDateTrustView;

@end

@implementation WonAlertView

- (void)dealloc {
    
}

- (instancetype)initWithFrame:(CGRect)frame
                          title:(NSString *)title
                        message:(NSString *)message
                   dustManSplit:(NSArray<NSString *> *)dustManSplit
                     completion:(EditSoftDefineTwoFlowArts)completion {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        self.completion = completion;
        
        
        self.askNotBigPowerView = [[UIView alloc] init];
        self.askNotBigPowerView.backgroundColor = [BinFaxEight indentJobColor];
        self.askNotBigPowerView.layer.cornerRadius = BinFaxEight.icyAboutDrum.canTagEleven;
        self.askNotBigPowerView.clipsToBounds = YES;
        self.askNotBigPowerView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:self.askNotBigPowerView];
        
        
        [NSLayoutConstraint activateConstraints:@[
            [self.askNotBigPowerView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
            [self.askNotBigPowerView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
            [self.askNotBigPowerView.widthAnchor constraintEqualToConstant:270]
        ]];
        
        
        UIView *diagnoseView = nil;
        CGFloat followPoolLostFalloffDog = 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.askNotBigPowerView addSubview:titleLabel];
            
            [NSLayoutConstraint activateConstraints:@[
                [titleLabel.topAnchor constraintEqualToAnchor:self.askNotBigPowerView.topAnchor constant:followPoolLostFalloffDog],
                [titleLabel.leadingAnchor constraintEqualToAnchor:self.askNotBigPowerView.leadingAnchor constant:16],
                [titleLabel.trailingAnchor constraintEqualToAnchor:self.askNotBigPowerView.trailingAnchor constant:-16]
            ]];
            
            diagnoseView = titleLabel;
        }
        
        
        if (message.length > 0) {
            UILabel *herDrumLabel = [[UILabel alloc] init];
            herDrumLabel.text = message;
            herDrumLabel.textColor = UIColor.whiteColor;
            herDrumLabel.font = [UIFont systemFontOfSize:15];
            herDrumLabel.textAlignment = NSTextAlignmentCenter;
            herDrumLabel.numberOfLines = 0;
            herDrumLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.askNotBigPowerView addSubview:herDrumLabel];
            
            NSLayoutYAxisAnchor *topAnchor = diagnoseView ? diagnoseView.bottomAnchor : self.askNotBigPowerView.topAnchor;
            CGFloat bitSpeaker = diagnoseView ? 10 : followPoolLostFalloffDog;
            [NSLayoutConstraint activateConstraints:@[
                [herDrumLabel.topAnchor constraintEqualToAnchor:topAnchor constant:bitSpeaker],
                [herDrumLabel.leadingAnchor constraintEqualToAnchor:self.askNotBigPowerView.leadingAnchor constant:16],
                [herDrumLabel.trailingAnchor constraintEqualToAnchor:self.askNotBigPowerView.trailingAnchor constant:-16]
            ]];
            diagnoseView = herDrumLabel;
        }
        
        
        self.tenDateTrustView = [[UIStackView alloc] init];
        self.tenDateTrustView.axis = UILayoutConstraintAxisVertical;
        self.tenDateTrustView.spacing = 1;  
        self.tenDateTrustView.distribution = UIStackViewDistributionFillEqually;
        self.tenDateTrustView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.askNotBigPowerView addSubview:self.tenDateTrustView];
        
        
        NSLayoutYAxisAnchor *highestAscentReachedUnifyRound = diagnoseView ? diagnoseView.bottomAnchor : self.askNotBigPowerView.topAnchor;
        CGFloat twitterRuleDescenderCanceledLiter = diagnoseView ? followPoolLostFalloffDog : followPoolLostFalloffDog;
        
        [NSLayoutConstraint activateConstraints:@[
            [self.tenDateTrustView.topAnchor constraintEqualToAnchor:highestAscentReachedUnifyRound constant:twitterRuleDescenderCanceledLiter],
            [self.tenDateTrustView.leadingAnchor constraintEqualToAnchor:self.askNotBigPowerView.leadingAnchor],
            [self.tenDateTrustView.trailingAnchor constraintEqualToAnchor:self.askNotBigPowerView.trailingAnchor],
            [self.tenDateTrustView.bottomAnchor constraintEqualToAnchor:self.askNotBigPowerView.bottomAnchor]
        ]];
        
        
       
       if (dustManSplit.count == 2) {
           
           self.tenDateTrustView = [[UIStackView alloc] init];
           self.tenDateTrustView.axis = UILayoutConstraintAxisHorizontal;
           self.tenDateTrustView.distribution = UIStackViewDistributionFillEqually;
           self.tenDateTrustView.spacing = 1;  
           self.tenDateTrustView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.askNotBigPowerView addSubview:self.tenDateTrustView];
           
           NSLayoutYAxisAnchor *highestAscentReachedUnifyRound = diagnoseView ? diagnoseView.bottomAnchor : self.askNotBigPowerView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.tenDateTrustView.topAnchor constraintEqualToAnchor:highestAscentReachedUnifyRound constant:followPoolLostFalloffDog],
               [self.tenDateTrustView.leadingAnchor constraintEqualToAnchor:self.askNotBigPowerView.leadingAnchor],
               [self.tenDateTrustView.trailingAnchor constraintEqualToAnchor:self.askNotBigPowerView.trailingAnchor],
               [self.tenDateTrustView.bottomAnchor constraintEqualToAnchor:self.askNotBigPowerView.bottomAnchor]
           ]];
           
           
           for (NSInteger i = 0; i < dustManSplit.count; i++) {
               NSString *topEuler = dustManSplit[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:topEuler forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[BinFaxEight indentJobColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(swedishBleed:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.tenDateTrustView addArrangedSubview:button];
           }
       } else {
           
           self.tenDateTrustView = [[UIStackView alloc] init];
           self.tenDateTrustView.axis = UILayoutConstraintAxisVertical;
           self.tenDateTrustView.spacing = 1;
           self.tenDateTrustView.distribution = UIStackViewDistributionFillEqually;
           self.tenDateTrustView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.askNotBigPowerView addSubview:self.tenDateTrustView];
           
           NSLayoutYAxisAnchor *highestAscentReachedUnifyRound = diagnoseView ? diagnoseView.bottomAnchor : self.askNotBigPowerView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.tenDateTrustView.topAnchor constraintEqualToAnchor:highestAscentReachedUnifyRound constant:followPoolLostFalloffDog],
               [self.tenDateTrustView.leadingAnchor constraintEqualToAnchor:self.askNotBigPowerView.leadingAnchor],
               [self.tenDateTrustView.trailingAnchor constraintEqualToAnchor:self.askNotBigPowerView.trailingAnchor],
               [self.tenDateTrustView.bottomAnchor constraintEqualToAnchor:self.askNotBigPowerView.bottomAnchor]
           ]];
           
           for (NSInteger i = 0; i < dustManSplit.count; i++) {
               NSString *topEuler = dustManSplit[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:topEuler forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[BinFaxEight indentJobColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(swedishBleed:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.tenDateTrustView addArrangedSubview:button];
           }
       }
    }
    return self;
}

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

+ (void)terminalRetryCopperBookmarksRemainingIdle:(NSString *)title
                        message:(NSString *)message
                   dustManSplit:(NSArray<NSString *> *)dustManSplit
                     completion:(EditSoftDefineTwoFlowArts)completion {
    
    WonAlertView *rebus = [[WonAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          dustManSplit:dustManSplit
                                            completion:completion];
    
    
    [BalticFixManager.shared arrowTouchSunVerySmallOffsetView:rebus];
    
    
    rebus.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        rebus.alpha = 1.0;
    }];
}

+ (void)terminalRetryCopperBookmarksRemainingIdle:(NSString *)title message:(NSString *)message completion:(EditSoftDefineTwoFlowArts)completion {
    [self terminalRetryCopperBookmarksRemainingIdle:title message:message dustManSplit:@[BinFaxEight.signRoomModify.slowOdd] completion:completion];
}

@end
