






#import "BadAlertView.h"
#import "HexDiscrete.h"
#import "SoloSlantManager.h"
#import "Masonry.h"

#define lazyFax(law) __weak typeof(law) weak##law = law;
#define extendCat(law) __strong typeof(law) law = weak##law;

@interface BadAlertView()

@property (nonatomic, strong) UIView *ourLeadLineDogView;
@property (nonatomic, copy) CaseTargetRespectsDiscardTranslateEllipse completion;
@property (nonatomic, strong) UIStackView *northBoldAskView;

@end

@implementation BadAlertView

- (void)dealloc {
    
}

- (instancetype)initWithFrame:(CGRect)frame
                          title:(NSString *)title
                        message:(NSString *)message
                   armpitArtUse:(NSArray<NSString *> *)armpitArtUse
                     completion:(CaseTargetRespectsDiscardTranslateEllipse)completion {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        self.completion = completion;
        
        
        self.ourLeadLineDogView = [[UIView alloc] init];
        self.ourLeadLineDogView.backgroundColor = [HexDiscrete prominentColor];
        self.ourLeadLineDogView.layer.cornerRadius = HexDiscrete.shelfTenSide.dueMetalLink;
        self.ourLeadLineDogView.clipsToBounds = YES;
        self.ourLeadLineDogView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:self.ourLeadLineDogView];
        
        
        [NSLayoutConstraint activateConstraints:@[
            [self.ourLeadLineDogView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
            [self.ourLeadLineDogView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
            [self.ourLeadLineDogView.widthAnchor constraintEqualToConstant:270]
        ]];
        
        
        UIView *disabledView = nil;
        CGFloat gesturesCountSexTalkLess = 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.ourLeadLineDogView addSubview:titleLabel];
            
            [NSLayoutConstraint activateConstraints:@[
                [titleLabel.topAnchor constraintEqualToAnchor:self.ourLeadLineDogView.topAnchor constant:gesturesCountSexTalkLess],
                [titleLabel.leadingAnchor constraintEqualToAnchor:self.ourLeadLineDogView.leadingAnchor constant:16],
                [titleLabel.trailingAnchor constraintEqualToAnchor:self.ourLeadLineDogView.trailingAnchor constant:-16]
            ]];
            
            disabledView = titleLabel;
        }
        
        
        if (message.length > 0) {
            UILabel *anchorsLabel = [[UILabel alloc] init];
            anchorsLabel.text = message;
            anchorsLabel.textColor = UIColor.whiteColor;
            anchorsLabel.font = [UIFont systemFontOfSize:15];
            anchorsLabel.textAlignment = NSTextAlignmentCenter;
            anchorsLabel.numberOfLines = 0;
            anchorsLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.ourLeadLineDogView addSubview:anchorsLabel];
            
            NSLayoutYAxisAnchor *topAnchor = disabledView ? disabledView.bottomAnchor : self.ourLeadLineDogView.topAnchor;
            CGFloat bestMemory = disabledView ? 10 : gesturesCountSexTalkLess;
            [NSLayoutConstraint activateConstraints:@[
                [anchorsLabel.topAnchor constraintEqualToAnchor:topAnchor constant:bestMemory],
                [anchorsLabel.leadingAnchor constraintEqualToAnchor:self.ourLeadLineDogView.leadingAnchor constant:16],
                [anchorsLabel.trailingAnchor constraintEqualToAnchor:self.ourLeadLineDogView.trailingAnchor constant:-16]
            ]];
            disabledView = anchorsLabel;
        }
        
        
        self.northBoldAskView = [[UIStackView alloc] init];
        self.northBoldAskView.axis = UILayoutConstraintAxisVertical;
        self.northBoldAskView.spacing = 1;  
        self.northBoldAskView.distribution = UIStackViewDistributionFillEqually;
        self.northBoldAskView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.ourLeadLineDogView addSubview:self.northBoldAskView];
        
        
        NSLayoutYAxisAnchor *tabDueHomeBusContexts = disabledView ? disabledView.bottomAnchor : self.ourLeadLineDogView.topAnchor;
        CGFloat tabSequencesUnsavedYearManaged = disabledView ? gesturesCountSexTalkLess : gesturesCountSexTalkLess;
        
        [NSLayoutConstraint activateConstraints:@[
            [self.northBoldAskView.topAnchor constraintEqualToAnchor:tabDueHomeBusContexts constant:tabSequencesUnsavedYearManaged],
            [self.northBoldAskView.leadingAnchor constraintEqualToAnchor:self.ourLeadLineDogView.leadingAnchor],
            [self.northBoldAskView.trailingAnchor constraintEqualToAnchor:self.ourLeadLineDogView.trailingAnchor],
            [self.northBoldAskView.bottomAnchor constraintEqualToAnchor:self.ourLeadLineDogView.bottomAnchor]
        ]];
        
        
       
       if (armpitArtUse.count == 2) {
           
           self.northBoldAskView = [[UIStackView alloc] init];
           self.northBoldAskView.axis = UILayoutConstraintAxisHorizontal;
           self.northBoldAskView.distribution = UIStackViewDistributionFillEqually;
           self.northBoldAskView.spacing = 1;  
           self.northBoldAskView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.ourLeadLineDogView addSubview:self.northBoldAskView];
           
           NSLayoutYAxisAnchor *tabDueHomeBusContexts = disabledView ? disabledView.bottomAnchor : self.ourLeadLineDogView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.northBoldAskView.topAnchor constraintEqualToAnchor:tabDueHomeBusContexts constant:gesturesCountSexTalkLess],
               [self.northBoldAskView.leadingAnchor constraintEqualToAnchor:self.ourLeadLineDogView.leadingAnchor],
               [self.northBoldAskView.trailingAnchor constraintEqualToAnchor:self.ourLeadLineDogView.trailingAnchor],
               [self.northBoldAskView.bottomAnchor constraintEqualToAnchor:self.ourLeadLineDogView.bottomAnchor]
           ]];
           
           
           for (NSInteger i = 0; i < armpitArtUse.count; i++) {
               NSString *guidePen = armpitArtUse[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:guidePen forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[HexDiscrete prominentColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(sumTintModel:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.northBoldAskView addArrangedSubview:button];
           }
       } else {
           
           self.northBoldAskView = [[UIStackView alloc] init];
           self.northBoldAskView.axis = UILayoutConstraintAxisVertical;
           self.northBoldAskView.spacing = 1;
           self.northBoldAskView.distribution = UIStackViewDistributionFillEqually;
           self.northBoldAskView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.ourLeadLineDogView addSubview:self.northBoldAskView];
           
           NSLayoutYAxisAnchor *tabDueHomeBusContexts = disabledView ? disabledView.bottomAnchor : self.ourLeadLineDogView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.northBoldAskView.topAnchor constraintEqualToAnchor:tabDueHomeBusContexts constant:gesturesCountSexTalkLess],
               [self.northBoldAskView.leadingAnchor constraintEqualToAnchor:self.ourLeadLineDogView.leadingAnchor],
               [self.northBoldAskView.trailingAnchor constraintEqualToAnchor:self.ourLeadLineDogView.trailingAnchor],
               [self.northBoldAskView.bottomAnchor constraintEqualToAnchor:self.ourLeadLineDogView.bottomAnchor]
           ]];
           
           for (NSInteger i = 0; i < armpitArtUse.count; i++) {
               NSString *guidePen = armpitArtUse[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:guidePen forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[HexDiscrete prominentColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(sumTintModel:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.northBoldAskView addArrangedSubview:button];
           }
       }
    }
    return self;
}

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

+ (void)oddDepthCanUseTipWaist:(NSString *)title
                        message:(NSString *)message
                   armpitArtUse:(NSArray<NSString *> *)armpitArtUse
                     completion:(CaseTargetRespectsDiscardTranslateEllipse)completion {
    
    BadAlertView *bound = [[BadAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          armpitArtUse:armpitArtUse
                                            completion:completion];
    
    
    [SoloSlantManager.shared securelyArmBasalSuspendedAtomArmView:bound];
    
    
    bound.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        bound.alpha = 1.0;
    }];
}

+ (void)oddDepthCanUseTipWaist:(NSString *)title message:(NSString *)message completion:(CaseTargetRespectsDiscardTranslateEllipse)completion {
    [self oddDepthCanUseTipWaist:title message:message armpitArtUse:@[HexDiscrete.twistSheWasWin.tipPlug] completion:completion];
}

@end
