






#import "BitAlertView.h"
#import "SobIllWelsh.h"
#import "SleepPairManager.h"
#import "Masonry.h"

#define descent(our) __weak typeof(our) weak##our = our;
#define unbounded(our) __strong typeof(our) our = weak##our;

@interface BitAlertView()

@property (nonatomic, strong) UIView *howFilmPongAgeView;
@property (nonatomic, copy) DescentAppliesLingerExemplarParserRow completion;
@property (nonatomic, strong) UIStackView *mismatchHeapView;

@end

@implementation BitAlertView

- (void)dealloc {
    
}

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

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

+ (void)combinedSymbolsConjugateOptReuseFarthest:(NSString *)title
                        message:(NSString *)message
                   lossAccuracy:(NSArray<NSString *> *)lossAccuracy
                     completion:(DescentAppliesLingerExemplarParserRow)completion {
    
    BitAlertView *setup = [[BitAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          lossAccuracy:lossAccuracy
                                            completion:completion];
    
    
    [SleepPairManager.shared calendarSenderBehaviorsRandomMustPlainView:setup];
    
    
    setup.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        setup.alpha = 1.0;
    }];
}

+ (void)combinedSymbolsConjugateOptReuseFarthest:(NSString *)title message:(NSString *)message completion:(DescentAppliesLingerExemplarParserRow)completion {
    [self combinedSymbolsConjugateOptReuseFarthest:title message:message lossAccuracy:@[SobIllWelsh.notHeapPeerRed.foodBad] completion:completion];
}

@end
