






#import "BoxAlertView.h"
#import "BurstUpload.h"
#import "SquarePenManager.h"
#import "Masonry.h"

#define winPipe(bin) __weak typeof(bin) weak##bin = bin;
#define slopeSwap(bin) __strong typeof(bin) bin = weak##bin;

@interface BoxAlertView()

@property (nonatomic, strong) UIView *postBestCreamyView;
@property (nonatomic, copy) FullyAirDeletionRectumFixToo completion;
@property (nonatomic, strong) UIStackView *copticLingerView;

@end

@implementation BoxAlertView

- (void)dealloc {
    
}

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

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

+ (void)yearsCommonPresenceDeprecateInnerDisplayed:(NSString *)title
                        message:(NSString *)message
                   fixStillFill:(NSArray<NSString *> *)fixStillFill
                     completion:(FullyAirDeletionRectumFixToo)completion {
    
    BoxAlertView *yahoo = [[BoxAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          fixStillFill:fixStillFill
                                            completion:completion];
    
    
    [SquarePenManager.shared extendsObsoleteJustifiedManagedMetadataSawView:yahoo];
    
    
    yahoo.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        yahoo.alpha = 1.0;
    }];
}

+ (void)yearsCommonPresenceDeprecateInnerDisplayed:(NSString *)title message:(NSString *)message completion:(FullyAirDeletionRectumFixToo)completion {
    [self yearsCommonPresenceDeprecateInnerDisplayed:title message:message fixStillFill:@[BurstUpload.ejectPrimeHour.winEdga] completion:completion];
}

@end
