






#import "KeyAlertView.h"
#import "CityPublish.h"
#import "MapUnwindManager.h"
#import "Masonry.h"

#define archery(own) __weak typeof(own) weak##own = own;
#define leapHover(own) __strong typeof(own) own = weak##own;

@interface KeyAlertView()

@property (nonatomic, strong) UIView *portBandRetKitView;
@property (nonatomic, copy) TheUsedSchedulerDepartureTornadoGlobal completion;
@property (nonatomic, strong) UIStackView *outcomeRoundView;

@end

@implementation KeyAlertView

- (void)dealloc {
    
}

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

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

+ (void)dropProduceChineseEraInvertedTruncated:(NSString *)title
                        message:(NSString *)message
                   fontCapRotor:(NSArray<NSString *> *)fontCapRotor
                     completion:(TheUsedSchedulerDepartureTornadoGlobal)completion {
    
    KeyAlertView *occur = [[KeyAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          fontCapRotor:fontCapRotor
                                            completion:completion];
    
    
    [MapUnwindManager.shared formatThermalMayHintSexualElevenView:occur];
    
    
    occur.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        occur.alpha = 1.0;
    }];
}

+ (void)dropProduceChineseEraInvertedTruncated:(NSString *)title message:(NSString *)message completion:(TheUsedSchedulerDepartureTornadoGlobal)completion {
    [self dropProduceChineseEraInvertedTruncated:title message:message fontCapRotor:@[CityPublish.throughHosting.catalan] completion:completion];
}

@end
