






#import "CapAlertView.h"
#import "SkinMeanYet.h"
#import "TeaspoonsManager.h"
#import "Masonry.h"

#define bondIcy(out) __weak typeof(out) weak##out = out;
#define askArtery(out) __strong typeof(out) out = weak##out;

@interface CapAlertView()

@property (nonatomic, strong) UIView *channelsResignView;
@property (nonatomic, copy) MountItalicsRevealedBarOffHand completion;
@property (nonatomic, strong) UIStackView *alphaFeatFatView;

@end

@implementation CapAlertView

- (void)dealloc {
    
}

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

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

+ (void)farMetabolicStrictlyThresholdEraEither:(NSString *)title
                        message:(NSString *)message
                   allowableWax:(NSArray<NSString *> *)allowableWax
                     completion:(MountItalicsRevealedBarOffHand)completion {
    
    CapAlertView *radio = [[CapAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          allowableWax:allowableWax
                                            completion:completion];
    
    
    [TeaspoonsManager.shared installHandleCameraHandlingDirtyLargestView:radio];
    
    
    radio.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        radio.alpha = 1.0;
    }];
}

+ (void)farMetabolicStrictlyThresholdEraEither:(NSString *)title message:(NSString *)message completion:(MountItalicsRevealedBarOffHand)completion {
    [self farMetabolicStrictlyThresholdEraEither:title message:message allowableWax:@[SkinMeanYet.faxHoldTakePin.seeFact] completion:completion];
}

@end
