






#import "FunAlertView.h"
#import "SkinEchoMen.h"
#import "OutDemandManager.h"
#import "Masonry.h"

#define turnOne(who) __weak typeof(who) weak##who = who;
#define answerSaw(who) __strong typeof(who) who = weak##who;

@interface FunAlertView()

@property (nonatomic, strong) UIView *dietaryScalingView;
@property (nonatomic, copy) SquareDecayWaySoundSonLetters completion;
@property (nonatomic, strong) UIStackView *foggyCupFadeView;

@end

@implementation FunAlertView

- (void)dealloc {
    
}

- (instancetype)initWithFrame:(CGRect)frame
                          title:(NSString *)title
                        message:(NSString *)message
                   ageWalkTeeth:(NSArray<NSString *> *)ageWalkTeeth
                     completion:(SquareDecayWaySoundSonLetters)completion {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        self.completion = completion;
        
        
        self.dietaryScalingView = [[UIView alloc] init];
        self.dietaryScalingView.backgroundColor = [SkinEchoMen panoramasColor];
        self.dietaryScalingView.layer.cornerRadius = SkinEchoMen.pauseKirghiz.downBinVital;
        self.dietaryScalingView.clipsToBounds = YES;
        self.dietaryScalingView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:self.dietaryScalingView];
        
        
        [NSLayoutConstraint activateConstraints:@[
            [self.dietaryScalingView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
            [self.dietaryScalingView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
            [self.dietaryScalingView.widthAnchor constraintEqualToConstant:270]
        ]];
        
        
        UIView *forwardsView = nil;
        CGFloat eraserUnlockSockPeakConfigure = 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.dietaryScalingView addSubview:titleLabel];
            
            [NSLayoutConstraint activateConstraints:@[
                [titleLabel.topAnchor constraintEqualToAnchor:self.dietaryScalingView.topAnchor constant:eraserUnlockSockPeakConfigure],
                [titleLabel.leadingAnchor constraintEqualToAnchor:self.dietaryScalingView.leadingAnchor constant:16],
                [titleLabel.trailingAnchor constraintEqualToAnchor:self.dietaryScalingView.trailingAnchor constant:-16]
            ]];
            
            forwardsView = titleLabel;
        }
        
        
        if (message.length > 0) {
            UILabel *sizeCutLabel = [[UILabel alloc] init];
            sizeCutLabel.text = message;
            sizeCutLabel.textColor = UIColor.whiteColor;
            sizeCutLabel.font = [UIFont systemFontOfSize:15];
            sizeCutLabel.textAlignment = NSTextAlignmentCenter;
            sizeCutLabel.numberOfLines = 0;
            sizeCutLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.dietaryScalingView addSubview:sizeCutLabel];
            
            NSLayoutYAxisAnchor *topAnchor = forwardsView ? forwardsView.bottomAnchor : self.dietaryScalingView.topAnchor;
            CGFloat openUrgent = forwardsView ? 10 : eraserUnlockSockPeakConfigure;
            [NSLayoutConstraint activateConstraints:@[
                [sizeCutLabel.topAnchor constraintEqualToAnchor:topAnchor constant:openUrgent],
                [sizeCutLabel.leadingAnchor constraintEqualToAnchor:self.dietaryScalingView.leadingAnchor constant:16],
                [sizeCutLabel.trailingAnchor constraintEqualToAnchor:self.dietaryScalingView.trailingAnchor constant:-16]
            ]];
            forwardsView = sizeCutLabel;
        }
        
        
        self.foggyCupFadeView = [[UIStackView alloc] init];
        self.foggyCupFadeView.axis = UILayoutConstraintAxisVertical;
        self.foggyCupFadeView.spacing = 1;  
        self.foggyCupFadeView.distribution = UIStackViewDistributionFillEqually;
        self.foggyCupFadeView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.dietaryScalingView addSubview:self.foggyCupFadeView];
        
        
        NSLayoutYAxisAnchor *metadataMostlySpectralForCandidate = forwardsView ? forwardsView.bottomAnchor : self.dietaryScalingView.topAnchor;
        CGFloat localizesTrustedDecodePosterPrime = forwardsView ? eraserUnlockSockPeakConfigure : eraserUnlockSockPeakConfigure;
        
        [NSLayoutConstraint activateConstraints:@[
            [self.foggyCupFadeView.topAnchor constraintEqualToAnchor:metadataMostlySpectralForCandidate constant:localizesTrustedDecodePosterPrime],
            [self.foggyCupFadeView.leadingAnchor constraintEqualToAnchor:self.dietaryScalingView.leadingAnchor],
            [self.foggyCupFadeView.trailingAnchor constraintEqualToAnchor:self.dietaryScalingView.trailingAnchor],
            [self.foggyCupFadeView.bottomAnchor constraintEqualToAnchor:self.dietaryScalingView.bottomAnchor]
        ]];
        
        
       
       if (ageWalkTeeth.count == 2) {
           
           self.foggyCupFadeView = [[UIStackView alloc] init];
           self.foggyCupFadeView.axis = UILayoutConstraintAxisHorizontal;
           self.foggyCupFadeView.distribution = UIStackViewDistributionFillEqually;
           self.foggyCupFadeView.spacing = 1;  
           self.foggyCupFadeView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.dietaryScalingView addSubview:self.foggyCupFadeView];
           
           NSLayoutYAxisAnchor *metadataMostlySpectralForCandidate = forwardsView ? forwardsView.bottomAnchor : self.dietaryScalingView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.foggyCupFadeView.topAnchor constraintEqualToAnchor:metadataMostlySpectralForCandidate constant:eraserUnlockSockPeakConfigure],
               [self.foggyCupFadeView.leadingAnchor constraintEqualToAnchor:self.dietaryScalingView.leadingAnchor],
               [self.foggyCupFadeView.trailingAnchor constraintEqualToAnchor:self.dietaryScalingView.trailingAnchor],
               [self.foggyCupFadeView.bottomAnchor constraintEqualToAnchor:self.dietaryScalingView.bottomAnchor]
           ]];
           
           
           for (NSInteger i = 0; i < ageWalkTeeth.count; i++) {
               NSString *leftChat = ageWalkTeeth[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:leftChat forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[SkinEchoMen panoramasColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(ratioTagNote:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.foggyCupFadeView addArrangedSubview:button];
           }
       } else {
           
           self.foggyCupFadeView = [[UIStackView alloc] init];
           self.foggyCupFadeView.axis = UILayoutConstraintAxisVertical;
           self.foggyCupFadeView.spacing = 1;
           self.foggyCupFadeView.distribution = UIStackViewDistributionFillEqually;
           self.foggyCupFadeView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.dietaryScalingView addSubview:self.foggyCupFadeView];
           
           NSLayoutYAxisAnchor *metadataMostlySpectralForCandidate = forwardsView ? forwardsView.bottomAnchor : self.dietaryScalingView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.foggyCupFadeView.topAnchor constraintEqualToAnchor:metadataMostlySpectralForCandidate constant:eraserUnlockSockPeakConfigure],
               [self.foggyCupFadeView.leadingAnchor constraintEqualToAnchor:self.dietaryScalingView.leadingAnchor],
               [self.foggyCupFadeView.trailingAnchor constraintEqualToAnchor:self.dietaryScalingView.trailingAnchor],
               [self.foggyCupFadeView.bottomAnchor constraintEqualToAnchor:self.dietaryScalingView.bottomAnchor]
           ]];
           
           for (NSInteger i = 0; i < ageWalkTeeth.count; i++) {
               NSString *leftChat = ageWalkTeeth[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:leftChat forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[SkinEchoMen panoramasColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(ratioTagNote:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.foggyCupFadeView addArrangedSubview:button];
           }
       }
    }
    return self;
}

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

+ (void)thirdExecFunnelNapFrenchPeriodic:(NSString *)title
                        message:(NSString *)message
                   ageWalkTeeth:(NSArray<NSString *> *)ageWalkTeeth
                     completion:(SquareDecayWaySoundSonLetters)completion {
    
    FunAlertView *setup = [[FunAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          ageWalkTeeth:ageWalkTeeth
                                            completion:completion];
    
    
    [OutDemandManager.shared expectingDescentFiberBarrierSourcesThermalView:setup];
    
    
    setup.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        setup.alpha = 1.0;
    }];
}

+ (void)thirdExecFunnelNapFrenchPeriodic:(NSString *)title message:(NSString *)message completion:(SquareDecayWaySoundSonLetters)completion {
    [self thirdExecFunnelNapFrenchPeriodic:title message:message ageWalkTeeth:@[SkinEchoMen.cubePrimeToken.company] completion:completion];
}

@end
