






#import "WaxAlertView.h"
#import "PriorEarSee.h"
#import "WeekChainManager.h"
#import "Masonry.h"

#define partial(bag) __weak typeof(bag) weak##bag = bag;
#define italicLaw(bag) __strong typeof(bag) bag = weak##bag;

@interface WaxAlertView()

@property (nonatomic, strong) UIView *askAllPhotoNetView;
@property (nonatomic, copy) InactiveDescenderPieceMapHoverSolutions completion;
@property (nonatomic, strong) UIStackView *thinHisMonthView;

@end

@implementation WaxAlertView

- (void)dealloc {
    
}

- (instancetype)initWithFrame:(CGRect)frame
                          title:(NSString *)title
                        message:(NSString *)message
                   serialArtRed:(NSArray<NSString *> *)serialArtRed
                     completion:(InactiveDescenderPieceMapHoverSolutions)completion {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        self.completion = completion;
        
        
        self.askAllPhotoNetView = [[UIView alloc] init];
        self.askAllPhotoNetView.backgroundColor = [PriorEarSee seeKazakhColor];
        self.askAllPhotoNetView.layer.cornerRadius = PriorEarSee.netListPhoto.ownChromaToo;
        self.askAllPhotoNetView.clipsToBounds = YES;
        self.askAllPhotoNetView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:self.askAllPhotoNetView];
        
        
        [NSLayoutConstraint activateConstraints:@[
            [self.askAllPhotoNetView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
            [self.askAllPhotoNetView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
            [self.askAllPhotoNetView.widthAnchor constraintEqualToConstant:270]
        ]];
        
        
        UIView *lostBandView = nil;
        CGFloat blockerDetachingProteinBundlesDiscarded = 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.askAllPhotoNetView addSubview:titleLabel];
            
            [NSLayoutConstraint activateConstraints:@[
                [titleLabel.topAnchor constraintEqualToAnchor:self.askAllPhotoNetView.topAnchor constant:blockerDetachingProteinBundlesDiscarded],
                [titleLabel.leadingAnchor constraintEqualToAnchor:self.askAllPhotoNetView.leadingAnchor constant:16],
                [titleLabel.trailingAnchor constraintEqualToAnchor:self.askAllPhotoNetView.trailingAnchor constant:-16]
            ]];
            
            lostBandView = titleLabel;
        }
        
        
        if (message.length > 0) {
            UILabel *settingLabel = [[UILabel alloc] init];
            settingLabel.text = message;
            settingLabel.textColor = UIColor.whiteColor;
            settingLabel.font = [UIFont systemFontOfSize:15];
            settingLabel.textAlignment = NSTextAlignmentCenter;
            settingLabel.numberOfLines = 0;
            settingLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.askAllPhotoNetView addSubview:settingLabel];
            
            NSLayoutYAxisAnchor *topAnchor = lostBandView ? lostBandView.bottomAnchor : self.askAllPhotoNetView.topAnchor;
            CGFloat canMayThat = lostBandView ? 10 : blockerDetachingProteinBundlesDiscarded;
            [NSLayoutConstraint activateConstraints:@[
                [settingLabel.topAnchor constraintEqualToAnchor:topAnchor constant:canMayThat],
                [settingLabel.leadingAnchor constraintEqualToAnchor:self.askAllPhotoNetView.leadingAnchor constant:16],
                [settingLabel.trailingAnchor constraintEqualToAnchor:self.askAllPhotoNetView.trailingAnchor constant:-16]
            ]];
            lostBandView = settingLabel;
        }
        
        
        self.thinHisMonthView = [[UIStackView alloc] init];
        self.thinHisMonthView.axis = UILayoutConstraintAxisVertical;
        self.thinHisMonthView.spacing = 1;  
        self.thinHisMonthView.distribution = UIStackViewDistributionFillEqually;
        self.thinHisMonthView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.askAllPhotoNetView addSubview:self.thinHisMonthView];
        
        
        NSLayoutYAxisAnchor *artMindAutomaticDiskMust = lostBandView ? lostBandView.bottomAnchor : self.askAllPhotoNetView.topAnchor;
        CGFloat warnDoubleSelectionKerningSmaller = lostBandView ? blockerDetachingProteinBundlesDiscarded : blockerDetachingProteinBundlesDiscarded;
        
        [NSLayoutConstraint activateConstraints:@[
            [self.thinHisMonthView.topAnchor constraintEqualToAnchor:artMindAutomaticDiskMust constant:warnDoubleSelectionKerningSmaller],
            [self.thinHisMonthView.leadingAnchor constraintEqualToAnchor:self.askAllPhotoNetView.leadingAnchor],
            [self.thinHisMonthView.trailingAnchor constraintEqualToAnchor:self.askAllPhotoNetView.trailingAnchor],
            [self.thinHisMonthView.bottomAnchor constraintEqualToAnchor:self.askAllPhotoNetView.bottomAnchor]
        ]];
        
        
       
       if (serialArtRed.count == 2) {
           
           self.thinHisMonthView = [[UIStackView alloc] init];
           self.thinHisMonthView.axis = UILayoutConstraintAxisHorizontal;
           self.thinHisMonthView.distribution = UIStackViewDistributionFillEqually;
           self.thinHisMonthView.spacing = 1;  
           self.thinHisMonthView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.askAllPhotoNetView addSubview:self.thinHisMonthView];
           
           NSLayoutYAxisAnchor *artMindAutomaticDiskMust = lostBandView ? lostBandView.bottomAnchor : self.askAllPhotoNetView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.thinHisMonthView.topAnchor constraintEqualToAnchor:artMindAutomaticDiskMust constant:blockerDetachingProteinBundlesDiscarded],
               [self.thinHisMonthView.leadingAnchor constraintEqualToAnchor:self.askAllPhotoNetView.leadingAnchor],
               [self.thinHisMonthView.trailingAnchor constraintEqualToAnchor:self.askAllPhotoNetView.trailingAnchor],
               [self.thinHisMonthView.bottomAnchor constraintEqualToAnchor:self.askAllPhotoNetView.bottomAnchor]
           ]];
           
           
           for (NSInteger i = 0; i < serialArtRed.count; i++) {
               NSString *haveBank = serialArtRed[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:haveBank forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[PriorEarSee seeKazakhColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(areaAddClang:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.thinHisMonthView addArrangedSubview:button];
           }
       } else {
           
           self.thinHisMonthView = [[UIStackView alloc] init];
           self.thinHisMonthView.axis = UILayoutConstraintAxisVertical;
           self.thinHisMonthView.spacing = 1;
           self.thinHisMonthView.distribution = UIStackViewDistributionFillEqually;
           self.thinHisMonthView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.askAllPhotoNetView addSubview:self.thinHisMonthView];
           
           NSLayoutYAxisAnchor *artMindAutomaticDiskMust = lostBandView ? lostBandView.bottomAnchor : self.askAllPhotoNetView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.thinHisMonthView.topAnchor constraintEqualToAnchor:artMindAutomaticDiskMust constant:blockerDetachingProteinBundlesDiscarded],
               [self.thinHisMonthView.leadingAnchor constraintEqualToAnchor:self.askAllPhotoNetView.leadingAnchor],
               [self.thinHisMonthView.trailingAnchor constraintEqualToAnchor:self.askAllPhotoNetView.trailingAnchor],
               [self.thinHisMonthView.bottomAnchor constraintEqualToAnchor:self.askAllPhotoNetView.bottomAnchor]
           ]];
           
           for (NSInteger i = 0; i < serialArtRed.count; i++) {
               NSString *haveBank = serialArtRed[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:haveBank forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[PriorEarSee seeKazakhColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(areaAddClang:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.thinHisMonthView addArrangedSubview:button];
           }
       }
    }
    return self;
}

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

+ (void)panControlsResonantFarWrestlingObserve:(NSString *)title
                        message:(NSString *)message
                   serialArtRed:(NSArray<NSString *> *)serialArtRed
                     completion:(InactiveDescenderPieceMapHoverSolutions)completion {
    
    WaxAlertView *hover = [[WaxAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          serialArtRed:serialArtRed
                                            completion:completion];
    
    
    [WeekChainManager.shared readBarsHitKnowCarCriticalView:hover];
    
    
    hover.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        hover.alpha = 1.0;
    }];
}

+ (void)panControlsResonantFarWrestlingObserve:(NSString *)title message:(NSString *)message completion:(InactiveDescenderPieceMapHoverSolutions)completion {
    [self panControlsResonantFarWrestlingObserve:title message:message serialArtRed:@[PriorEarSee.drawCreditLeft.fullBin] completion:completion];
}

@end
