






#import "KeyAlertView.h"
#import "SaveWayTaps.h"
#import "PrimeArtsManager.h"
#import "Masonry.h"

#define liveFix(how) __weak typeof(how) weak##how = how;
#define fitPartly(how) __strong typeof(how) how = weak##how;

@interface KeyAlertView()

@property (nonatomic, strong) UIView *capturedModernView;
@property (nonatomic, copy) NoteEnsureMagneticBlusteryCanonicalOuter completion;
@property (nonatomic, strong) UIStackView *inputSubjectView;

@end

@implementation KeyAlertView

- (void)dealloc {
    
}

- (instancetype)initWithFrame:(CGRect)frame
                          title:(NSString *)title
                        message:(NSString *)message
                   netLanguages:(NSArray<NSString *> *)netLanguages
                     completion:(NoteEnsureMagneticBlusteryCanonicalOuter)completion {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        self.completion = completion;
        
        
        self.capturedModernView = [[UIView alloc] init];
        self.capturedModernView.backgroundColor = [SaveWayTaps divideRunColor];
        self.capturedModernView.layer.cornerRadius = SaveWayTaps.offerHitEasy.zipSideCanon;
        self.capturedModernView.clipsToBounds = YES;
        self.capturedModernView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:self.capturedModernView];
        
        
        [NSLayoutConstraint activateConstraints:@[
            [self.capturedModernView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
            [self.capturedModernView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
            [self.capturedModernView.widthAnchor constraintEqualToConstant:270]
        ]];
        
        
        UIView *edgaBlueView = nil;
        CGFloat equalSaturatedPutGlucoseMale = 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.capturedModernView addSubview:titleLabel];
            
            [NSLayoutConstraint activateConstraints:@[
                [titleLabel.topAnchor constraintEqualToAnchor:self.capturedModernView.topAnchor constant:equalSaturatedPutGlucoseMale],
                [titleLabel.leadingAnchor constraintEqualToAnchor:self.capturedModernView.leadingAnchor constant:16],
                [titleLabel.trailingAnchor constraintEqualToAnchor:self.capturedModernView.trailingAnchor constant:-16]
            ]];
            
            edgaBlueView = titleLabel;
        }
        
        
        if (message.length > 0) {
            UILabel *canHeapLabel = [[UILabel alloc] init];
            canHeapLabel.text = message;
            canHeapLabel.textColor = UIColor.whiteColor;
            canHeapLabel.font = [UIFont systemFontOfSize:15];
            canHeapLabel.textAlignment = NSTextAlignmentCenter;
            canHeapLabel.numberOfLines = 0;
            canHeapLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.capturedModernView addSubview:canHeapLabel];
            
            NSLayoutYAxisAnchor *topAnchor = edgaBlueView ? edgaBlueView.bottomAnchor : self.capturedModernView.topAnchor;
            CGFloat dragOddSex = edgaBlueView ? 10 : equalSaturatedPutGlucoseMale;
            [NSLayoutConstraint activateConstraints:@[
                [canHeapLabel.topAnchor constraintEqualToAnchor:topAnchor constant:dragOddSex],
                [canHeapLabel.leadingAnchor constraintEqualToAnchor:self.capturedModernView.leadingAnchor constant:16],
                [canHeapLabel.trailingAnchor constraintEqualToAnchor:self.capturedModernView.trailingAnchor constant:-16]
            ]];
            edgaBlueView = canHeapLabel;
        }
        
        
        self.inputSubjectView = [[UIStackView alloc] init];
        self.inputSubjectView.axis = UILayoutConstraintAxisVertical;
        self.inputSubjectView.spacing = 1;  
        self.inputSubjectView.distribution = UIStackViewDistributionFillEqually;
        self.inputSubjectView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.capturedModernView addSubview:self.inputSubjectView];
        
        
        NSLayoutYAxisAnchor *intersectHandPositionTenRhythm = edgaBlueView ? edgaBlueView.bottomAnchor : self.capturedModernView.topAnchor;
        CGFloat hockeyVolatilePlanarScopeEgg = edgaBlueView ? equalSaturatedPutGlucoseMale : equalSaturatedPutGlucoseMale;
        
        [NSLayoutConstraint activateConstraints:@[
            [self.inputSubjectView.topAnchor constraintEqualToAnchor:intersectHandPositionTenRhythm constant:hockeyVolatilePlanarScopeEgg],
            [self.inputSubjectView.leadingAnchor constraintEqualToAnchor:self.capturedModernView.leadingAnchor],
            [self.inputSubjectView.trailingAnchor constraintEqualToAnchor:self.capturedModernView.trailingAnchor],
            [self.inputSubjectView.bottomAnchor constraintEqualToAnchor:self.capturedModernView.bottomAnchor]
        ]];
        
        
       
       if (netLanguages.count == 2) {
           
           self.inputSubjectView = [[UIStackView alloc] init];
           self.inputSubjectView.axis = UILayoutConstraintAxisHorizontal;
           self.inputSubjectView.distribution = UIStackViewDistributionFillEqually;
           self.inputSubjectView.spacing = 1;  
           self.inputSubjectView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.capturedModernView addSubview:self.inputSubjectView];
           
           NSLayoutYAxisAnchor *intersectHandPositionTenRhythm = edgaBlueView ? edgaBlueView.bottomAnchor : self.capturedModernView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.inputSubjectView.topAnchor constraintEqualToAnchor:intersectHandPositionTenRhythm constant:equalSaturatedPutGlucoseMale],
               [self.inputSubjectView.leadingAnchor constraintEqualToAnchor:self.capturedModernView.leadingAnchor],
               [self.inputSubjectView.trailingAnchor constraintEqualToAnchor:self.capturedModernView.trailingAnchor],
               [self.inputSubjectView.bottomAnchor constraintEqualToAnchor:self.capturedModernView.bottomAnchor]
           ]];
           
           
           for (NSInteger i = 0; i < netLanguages.count; i++) {
               NSString *appleFun = netLanguages[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:appleFun forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[SaveWayTaps divideRunColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(bringAreaToo:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.inputSubjectView addArrangedSubview:button];
           }
       } else {
           
           self.inputSubjectView = [[UIStackView alloc] init];
           self.inputSubjectView.axis = UILayoutConstraintAxisVertical;
           self.inputSubjectView.spacing = 1;
           self.inputSubjectView.distribution = UIStackViewDistributionFillEqually;
           self.inputSubjectView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.capturedModernView addSubview:self.inputSubjectView];
           
           NSLayoutYAxisAnchor *intersectHandPositionTenRhythm = edgaBlueView ? edgaBlueView.bottomAnchor : self.capturedModernView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.inputSubjectView.topAnchor constraintEqualToAnchor:intersectHandPositionTenRhythm constant:equalSaturatedPutGlucoseMale],
               [self.inputSubjectView.leadingAnchor constraintEqualToAnchor:self.capturedModernView.leadingAnchor],
               [self.inputSubjectView.trailingAnchor constraintEqualToAnchor:self.capturedModernView.trailingAnchor],
               [self.inputSubjectView.bottomAnchor constraintEqualToAnchor:self.capturedModernView.bottomAnchor]
           ]];
           
           for (NSInteger i = 0; i < netLanguages.count; i++) {
               NSString *appleFun = netLanguages[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:appleFun forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[SaveWayTaps divideRunColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(bringAreaToo:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.inputSubjectView addArrangedSubview:button];
           }
       }
    }
    return self;
}

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

+ (void)getHerSpaceVideoClusterExpanded:(NSString *)title
                        message:(NSString *)message
                   netLanguages:(NSArray<NSString *> *)netLanguages
                     completion:(NoteEnsureMagneticBlusteryCanonicalOuter)completion {
    
    KeyAlertView *infer = [[KeyAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          netLanguages:netLanguages
                                            completion:completion];
    
    
    [PrimeArtsManager.shared asleepExponentsResumeManganeseSelfScopeView:infer];
    
    
    infer.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        infer.alpha = 1.0;
    }];
}

+ (void)getHerSpaceVideoClusterExpanded:(NSString *)title message:(NSString *)message completion:(NoteEnsureMagneticBlusteryCanonicalOuter)completion {
    [self getHerSpaceVideoClusterExpanded:title message:message netLanguages:@[SaveWayTaps.hueOldAreaMole.borders] completion:completion];
}

@end
