






#import "HasAlertView.h"
#import "YahooKeyTip.h"
#import "AggregateManager.h"
#import "Masonry.h"

#define topLike(did) __weak typeof(did) weak##did = did;
#define dogManual(did) __strong typeof(did) did = weak##did;

@interface HasAlertView()

@property (nonatomic, strong) UIView *lappishPartnerView;
@property (nonatomic, copy) RollFoggyConductorSelectorsDebuggerGlobal completion;
@property (nonatomic, strong) UIStackView *hexBarThreadView;

@end

@implementation HasAlertView

- (void)dealloc {
    
}

- (instancetype)initWithFrame:(CGRect)frame
                          title:(NSString *)title
                        message:(NSString *)message
                   hairButPause:(NSArray<NSString *> *)hairButPause
                     completion:(RollFoggyConductorSelectorsDebuggerGlobal)completion {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        self.completion = completion;
        
        
        self.lappishPartnerView = [[UIView alloc] init];
        self.lappishPartnerView.backgroundColor = [YahooKeyTip expireCanColor];
        self.lappishPartnerView.layer.cornerRadius = YahooKeyTip.tatarMaximum.ironKinChain;
        self.lappishPartnerView.clipsToBounds = YES;
        self.lappishPartnerView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:self.lappishPartnerView];
        
        
        [NSLayoutConstraint activateConstraints:@[
            [self.lappishPartnerView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
            [self.lappishPartnerView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
            [self.lappishPartnerView.widthAnchor constraintEqualToConstant:270]
        ]];
        
        
        UIView *trackingView = nil;
        CGFloat potentialSentLikeConditionRebuild = 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.lappishPartnerView addSubview:titleLabel];
            
            [NSLayoutConstraint activateConstraints:@[
                [titleLabel.topAnchor constraintEqualToAnchor:self.lappishPartnerView.topAnchor constant:potentialSentLikeConditionRebuild],
                [titleLabel.leadingAnchor constraintEqualToAnchor:self.lappishPartnerView.leadingAnchor constant:16],
                [titleLabel.trailingAnchor constraintEqualToAnchor:self.lappishPartnerView.trailingAnchor constant:-16]
            ]];
            
            trackingView = titleLabel;
        }
        
        
        if (message.length > 0) {
            UILabel *overlapLabel = [[UILabel alloc] init];
            overlapLabel.text = message;
            overlapLabel.textColor = UIColor.whiteColor;
            overlapLabel.font = [UIFont systemFontOfSize:15];
            overlapLabel.textAlignment = NSTextAlignmentCenter;
            overlapLabel.numberOfLines = 0;
            overlapLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.lappishPartnerView addSubview:overlapLabel];
            
            NSLayoutYAxisAnchor *topAnchor = trackingView ? trackingView.bottomAnchor : self.lappishPartnerView.topAnchor;
            CGFloat scanDidRow = trackingView ? 10 : potentialSentLikeConditionRebuild;
            [NSLayoutConstraint activateConstraints:@[
                [overlapLabel.topAnchor constraintEqualToAnchor:topAnchor constant:scanDidRow],
                [overlapLabel.leadingAnchor constraintEqualToAnchor:self.lappishPartnerView.leadingAnchor constant:16],
                [overlapLabel.trailingAnchor constraintEqualToAnchor:self.lappishPartnerView.trailingAnchor constant:-16]
            ]];
            trackingView = overlapLabel;
        }
        
        
        self.hexBarThreadView = [[UIStackView alloc] init];
        self.hexBarThreadView.axis = UILayoutConstraintAxisVertical;
        self.hexBarThreadView.spacing = 1;  
        self.hexBarThreadView.distribution = UIStackViewDistributionFillEqually;
        self.hexBarThreadView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.lappishPartnerView addSubview:self.hexBarThreadView];
        
        
        NSLayoutYAxisAnchor *binQuoteCroppingUnderageHybrid = trackingView ? trackingView.bottomAnchor : self.lappishPartnerView.topAnchor;
        CGFloat tryMandarinDropFactPackage = trackingView ? potentialSentLikeConditionRebuild : potentialSentLikeConditionRebuild;
        
        [NSLayoutConstraint activateConstraints:@[
            [self.hexBarThreadView.topAnchor constraintEqualToAnchor:binQuoteCroppingUnderageHybrid constant:tryMandarinDropFactPackage],
            [self.hexBarThreadView.leadingAnchor constraintEqualToAnchor:self.lappishPartnerView.leadingAnchor],
            [self.hexBarThreadView.trailingAnchor constraintEqualToAnchor:self.lappishPartnerView.trailingAnchor],
            [self.hexBarThreadView.bottomAnchor constraintEqualToAnchor:self.lappishPartnerView.bottomAnchor]
        ]];
        
        
       
       if (hairButPause.count == 2) {
           
           self.hexBarThreadView = [[UIStackView alloc] init];
           self.hexBarThreadView.axis = UILayoutConstraintAxisHorizontal;
           self.hexBarThreadView.distribution = UIStackViewDistributionFillEqually;
           self.hexBarThreadView.spacing = 1;  
           self.hexBarThreadView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.lappishPartnerView addSubview:self.hexBarThreadView];
           
           NSLayoutYAxisAnchor *binQuoteCroppingUnderageHybrid = trackingView ? trackingView.bottomAnchor : self.lappishPartnerView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.hexBarThreadView.topAnchor constraintEqualToAnchor:binQuoteCroppingUnderageHybrid constant:potentialSentLikeConditionRebuild],
               [self.hexBarThreadView.leadingAnchor constraintEqualToAnchor:self.lappishPartnerView.leadingAnchor],
               [self.hexBarThreadView.trailingAnchor constraintEqualToAnchor:self.lappishPartnerView.trailingAnchor],
               [self.hexBarThreadView.bottomAnchor constraintEqualToAnchor:self.lappishPartnerView.bottomAnchor]
           ]];
           
           
           for (NSInteger i = 0; i < hairButPause.count; i++) {
               NSString *equalAre = hairButPause[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:equalAre forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[YahooKeyTip expireCanColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(softballHost:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.hexBarThreadView addArrangedSubview:button];
           }
       } else {
           
           self.hexBarThreadView = [[UIStackView alloc] init];
           self.hexBarThreadView.axis = UILayoutConstraintAxisVertical;
           self.hexBarThreadView.spacing = 1;
           self.hexBarThreadView.distribution = UIStackViewDistributionFillEqually;
           self.hexBarThreadView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.lappishPartnerView addSubview:self.hexBarThreadView];
           
           NSLayoutYAxisAnchor *binQuoteCroppingUnderageHybrid = trackingView ? trackingView.bottomAnchor : self.lappishPartnerView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.hexBarThreadView.topAnchor constraintEqualToAnchor:binQuoteCroppingUnderageHybrid constant:potentialSentLikeConditionRebuild],
               [self.hexBarThreadView.leadingAnchor constraintEqualToAnchor:self.lappishPartnerView.leadingAnchor],
               [self.hexBarThreadView.trailingAnchor constraintEqualToAnchor:self.lappishPartnerView.trailingAnchor],
               [self.hexBarThreadView.bottomAnchor constraintEqualToAnchor:self.lappishPartnerView.bottomAnchor]
           ]];
           
           for (NSInteger i = 0; i < hairButPause.count; i++) {
               NSString *equalAre = hairButPause[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:equalAre forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[YahooKeyTip expireCanColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(softballHost:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.hexBarThreadView addArrangedSubview:button];
           }
       }
    }
    return self;
}

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

+ (void)ringMountRemainingMattingGopherPin:(NSString *)title
                        message:(NSString *)message
                   hairButPause:(NSArray<NSString *> *)hairButPause
                     completion:(RollFoggyConductorSelectorsDebuggerGlobal)completion {
    
    HasAlertView *stood = [[HasAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          hairButPause:hairButPause
                                            completion:completion];
    
    
    [AggregateManager.shared linkRejectionLiveConsumesContextsUndefinedView:stood];
    
    
    stood.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        stood.alpha = 1.0;
    }];
}

+ (void)ringMountRemainingMattingGopherPin:(NSString *)title message:(NSString *)message completion:(RollFoggyConductorSelectorsDebuggerGlobal)completion {
    [self ringMountRemainingMattingGopherPin:title message:message hairButPause:@[YahooKeyTip.somaliLoopMove.threads] completion:completion];
}

@end
