






#import "EyeAlertView.h"
#import "ButPhonetic.h"
#import "WasFillerManager.h"
#import "Masonry.h"

#define yetGram(sun) __weak typeof(sun) weak##sun = sun;
#define herScript(sun) __strong typeof(sun) sun = weak##sun;

@interface EyeAlertView()

@property (nonatomic, strong) UIView *drainEggYetTapView;
@property (nonatomic, copy) IntroPriceFourthReportingSplitGasp completion;
@property (nonatomic, strong) UIStackView *modernColumnView;

@end

@implementation EyeAlertView

- (void)dealloc {
    
}

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

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

+ (void)layoutCupSetupBuiltSurfaceRank:(NSString *)title
                        message:(NSString *)message
                   foundSquares:(NSArray<NSString *> *)foundSquares
                     completion:(IntroPriceFourthReportingSplitGasp)completion {
    
    EyeAlertView *prime = [[EyeAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          foundSquares:foundSquares
                                            completion:completion];
    
    
    [WasFillerManager.shared sexQueueSoccerMemberBufferFatView:prime];
    
    
    prime.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        prime.alpha = 1.0;
    }];
}

+ (void)layoutCupSetupBuiltSurfaceRank:(NSString *)title message:(NSString *)message completion:(IntroPriceFourthReportingSplitGasp)completion {
    [self layoutCupSetupBuiltSurfaceRank:title message:message foundSquares:@[ButPhonetic.snowTabWhoDrum.floater] completion:completion];
}

@end
