






#import "NowAlertView.h"
#import "BinTopLemma.h"
#import "ChunkyGetManager.h"
#import "Masonry.h"

#define rawTurn(obj) __weak typeof(obj) weak##obj = obj;
#define exactWarn(obj) __strong typeof(obj) obj = weak##obj;

@interface NowAlertView()

@property (nonatomic, strong) UIView *burnSlabOptTopView;
@property (nonatomic, copy) AppliesOverlapDropRejectBadBuddhist completion;
@property (nonatomic, strong) UIStackView *occurRingNetView;

@end

@implementation NowAlertView

- (void)dealloc {
    
}

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

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

+ (void)prominentGoldenProfilesTropicalPivotViolation:(NSString *)title
                        message:(NSString *)message
                   ascendedTall:(NSArray<NSString *> *)ascendedTall
                     completion:(AppliesOverlapDropRejectBadBuddhist)completion {
    
    NowAlertView *malay = [[NowAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          ascendedTall:ascendedTall
                                            completion:completion];
    
    
    [ChunkyGetManager.shared optimizeZeroTextureConcertHaveRefusedView:malay];
    
    
    malay.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        malay.alpha = 1.0;
    }];
}

+ (void)prominentGoldenProfilesTropicalPivotViolation:(NSString *)title message:(NSString *)message completion:(AppliesOverlapDropRejectBadBuddhist)completion {
    [self prominentGoldenProfilesTropicalPivotViolation:title message:message ascendedTall:@[BinTopLemma.oldHitDownIron.specify] completion:completion];
}

@end
