






#import "MayAlertView.h"
#import "LeftHosting.h"
#import "AspectTapManager.h"
#import "Masonry.h"

#define sampler(pub) __weak typeof(pub) weak##pub = pub;
#define longerSun(pub) __strong typeof(pub) pub = weak##pub;

@interface MayAlertView()

@property (nonatomic, strong) UIView *cacheClipBlackView;
@property (nonatomic, copy) EditorialSignCellularShortFourEncipher completion;
@property (nonatomic, strong) UIStackView *parsecsPasteView;

@end

@implementation MayAlertView

- (void)dealloc {
    
}

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

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

+ (void)loopsFaxInferQuotationWrappingTip:(NSString *)title
                        message:(NSString *)message
                   faxFarOxygen:(NSArray<NSString *> *)faxFarOxygen
                     completion:(EditorialSignCellularShortFourEncipher)completion {
    
    MayAlertView *exist = [[MayAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          faxFarOxygen:faxFarOxygen
                                            completion:completion];
    
    
    [AspectTapManager.shared successHueBrowseEastMegahertzTenView:exist];
    
    
    exist.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        exist.alpha = 1.0;
    }];
}

+ (void)loopsFaxInferQuotationWrappingTip:(NSString *)title message:(NSString *)message completion:(EditorialSignCellularShortFourEncipher)completion {
    [self loopsFaxInferQuotationWrappingTip:title message:message faxFarOxygen:@[LeftHosting.carMapKeepPick.zoomLow] completion:completion];
}

@end
