






#import "AddAlertView.h"
#import "RaceRateYou.h"
#import "SeparatedManager.h"
#import "Masonry.h"

#define swahili(pen) __weak typeof(pen) weak##pen = pen;
#define linerNote(pen) __strong typeof(pen) pen = weak##pen;

@interface AddAlertView()

@property (nonatomic, strong) UIView *intentBandTakeView;
@property (nonatomic, copy) RankedStructureTooRefreshedClockwiseNumbers completion;
@property (nonatomic, strong) UIStackView *blindingDoneView;

@end

@implementation AddAlertView

- (void)dealloc {
    
}

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

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

+ (void)membersDeclinedSlideSobProcessesPlug:(NSString *)title
                        message:(NSString *)message
                   bendTotalMay:(NSArray<NSString *> *)bendTotalMay
                     completion:(RankedStructureTooRefreshedClockwiseNumbers)completion {
    
    AddAlertView *found = [[AddAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          bendTotalMay:bendTotalMay
                                            completion:completion];
    
    
    [SeparatedManager.shared topSheProblemConvertedEscapeChunkView:found];
    
    
    found.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        found.alpha = 1.0;
    }];
}

+ (void)membersDeclinedSlideSobProcessesPlug:(NSString *)title message:(NSString *)message completion:(RankedStructureTooRefreshedClockwiseNumbers)completion {
    [self membersDeclinedSlideSobProcessesPlug:title message:message bendTotalMay:@[RaceRateYou.maxSnapYearShe.twitter] completion:completion];
}

@end
