






#import "TwoAlertView.h"
#import "ClaimMaxBig.h"
#import "ZoneAngleManager.h"
#import "Masonry.h"

#define feature(opt) __weak typeof(opt) weak##opt = opt;
#define rowAttach(opt) __strong typeof(opt) opt = weak##opt;

@interface TwoAlertView()

@property (nonatomic, strong) UIView *sexWhoHoldRollView;
@property (nonatomic, copy) CarbonSeeRevisionMixRightMostly completion;
@property (nonatomic, strong) UIStackView *animatedTimeView;

@end

@implementation TwoAlertView

- (void)dealloc {
    
}

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

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

+ (void)oldDomainsDesignerSeeThreeAccurate:(NSString *)title
                        message:(NSString *)message
                   oneBusPreset:(NSArray<NSString *> *)oneBusPreset
                     completion:(CarbonSeeRevisionMixRightMostly)completion {
    
    TwoAlertView *greek = [[TwoAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          oneBusPreset:oneBusPreset
                                            completion:completion];
    
    
    [ZoneAngleManager.shared intentsArmourModerateDeletingFetchAmbiguityView:greek];
    
    
    greek.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        greek.alpha = 1.0;
    }];
}

+ (void)oldDomainsDesignerSeeThreeAccurate:(NSString *)title message:(NSString *)message completion:(CarbonSeeRevisionMixRightMostly)completion {
    [self oldDomainsDesignerSeeThreeAccurate:title message:message oneBusPreset:@[ClaimMaxBig.allFeedEarGolf.fatMove] completion:completion];
}

@end
