






#import "SixAlertView.h"
#import "OutTapPlain.h"
#import "AwayGlyphManager.h"
#import "Masonry.h"

#define spaBike(nap) __weak typeof(nap) weak##nap = nap;
#define parserWin(nap) __strong typeof(nap) nap = weak##nap;

@interface SixAlertView()

@property (nonatomic, strong) UIView *entityProfilesView;
@property (nonatomic, copy) RepublicPreparedDownRoomDisablesEnumerate completion;
@property (nonatomic, strong) UIStackView *cupIllDirectView;

@end

@implementation SixAlertView

- (void)dealloc {
    
}

- (instancetype)initWithFrame:(CGRect)frame
                          title:(NSString *)title
                        message:(NSString *)message
                   halfDispense:(NSArray<NSString *> *)halfDispense
                     completion:(RepublicPreparedDownRoomDisablesEnumerate)completion {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        self.completion = completion;
        
        
        self.entityProfilesView = [[UIView alloc] init];
        self.entityProfilesView.backgroundColor = [OutTapPlain bagOuncesColor];
        self.entityProfilesView.layer.cornerRadius = OutTapPlain.parentMixMay.transformFit;
        self.entityProfilesView.clipsToBounds = YES;
        self.entityProfilesView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:self.entityProfilesView];
        
        
        [NSLayoutConstraint activateConstraints:@[
            [self.entityProfilesView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
            [self.entityProfilesView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
            [self.entityProfilesView.widthAnchor constraintEqualToConstant:270]
        ]];
        
        
        UIView *cupIrishView = nil;
        CGFloat daughtersFreestyleCheckoutDiamondContainer = 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.entityProfilesView addSubview:titleLabel];
            
            [NSLayoutConstraint activateConstraints:@[
                [titleLabel.topAnchor constraintEqualToAnchor:self.entityProfilesView.topAnchor constant:daughtersFreestyleCheckoutDiamondContainer],
                [titleLabel.leadingAnchor constraintEqualToAnchor:self.entityProfilesView.leadingAnchor constant:16],
                [titleLabel.trailingAnchor constraintEqualToAnchor:self.entityProfilesView.trailingAnchor constant:-16]
            ]];
            
            cupIrishView = titleLabel;
        }
        
        
        if (message.length > 0) {
            UILabel *sigmoidLabel = [[UILabel alloc] init];
            sigmoidLabel.text = message;
            sigmoidLabel.textColor = UIColor.whiteColor;
            sigmoidLabel.font = [UIFont systemFontOfSize:15];
            sigmoidLabel.textAlignment = NSTextAlignmentCenter;
            sigmoidLabel.numberOfLines = 0;
            sigmoidLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.entityProfilesView addSubview:sigmoidLabel];
            
            NSLayoutYAxisAnchor *topAnchor = cupIrishView ? cupIrishView.bottomAnchor : self.entityProfilesView.topAnchor;
            CGFloat nineModule = cupIrishView ? 10 : daughtersFreestyleCheckoutDiamondContainer;
            [NSLayoutConstraint activateConstraints:@[
                [sigmoidLabel.topAnchor constraintEqualToAnchor:topAnchor constant:nineModule],
                [sigmoidLabel.leadingAnchor constraintEqualToAnchor:self.entityProfilesView.leadingAnchor constant:16],
                [sigmoidLabel.trailingAnchor constraintEqualToAnchor:self.entityProfilesView.trailingAnchor constant:-16]
            ]];
            cupIrishView = sigmoidLabel;
        }
        
        
        self.cupIllDirectView = [[UIStackView alloc] init];
        self.cupIllDirectView.axis = UILayoutConstraintAxisVertical;
        self.cupIllDirectView.spacing = 1;  
        self.cupIllDirectView.distribution = UIStackViewDistributionFillEqually;
        self.cupIllDirectView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.entityProfilesView addSubview:self.cupIllDirectView];
        
        
        NSLayoutYAxisAnchor *operationAudiencesAbsoluteRawVelocity = cupIrishView ? cupIrishView.bottomAnchor : self.entityProfilesView.topAnchor;
        CGFloat symmetricMegawattsGigahertzUnderFurlongs = cupIrishView ? daughtersFreestyleCheckoutDiamondContainer : daughtersFreestyleCheckoutDiamondContainer;
        
        [NSLayoutConstraint activateConstraints:@[
            [self.cupIllDirectView.topAnchor constraintEqualToAnchor:operationAudiencesAbsoluteRawVelocity constant:symmetricMegawattsGigahertzUnderFurlongs],
            [self.cupIllDirectView.leadingAnchor constraintEqualToAnchor:self.entityProfilesView.leadingAnchor],
            [self.cupIllDirectView.trailingAnchor constraintEqualToAnchor:self.entityProfilesView.trailingAnchor],
            [self.cupIllDirectView.bottomAnchor constraintEqualToAnchor:self.entityProfilesView.bottomAnchor]
        ]];
        
        
       
       if (halfDispense.count == 2) {
           
           self.cupIllDirectView = [[UIStackView alloc] init];
           self.cupIllDirectView.axis = UILayoutConstraintAxisHorizontal;
           self.cupIllDirectView.distribution = UIStackViewDistributionFillEqually;
           self.cupIllDirectView.spacing = 1;  
           self.cupIllDirectView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.entityProfilesView addSubview:self.cupIllDirectView];
           
           NSLayoutYAxisAnchor *operationAudiencesAbsoluteRawVelocity = cupIrishView ? cupIrishView.bottomAnchor : self.entityProfilesView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.cupIllDirectView.topAnchor constraintEqualToAnchor:operationAudiencesAbsoluteRawVelocity constant:daughtersFreestyleCheckoutDiamondContainer],
               [self.cupIllDirectView.leadingAnchor constraintEqualToAnchor:self.entityProfilesView.leadingAnchor],
               [self.cupIllDirectView.trailingAnchor constraintEqualToAnchor:self.entityProfilesView.trailingAnchor],
               [self.cupIllDirectView.bottomAnchor constraintEqualToAnchor:self.entityProfilesView.bottomAnchor]
           ]];
           
           
           for (NSInteger i = 0; i < halfDispense.count; i++) {
               NSString *cupSerif = halfDispense[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:cupSerif forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[OutTapPlain bagOuncesColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(numeratorCap:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.cupIllDirectView addArrangedSubview:button];
           }
       } else {
           
           self.cupIllDirectView = [[UIStackView alloc] init];
           self.cupIllDirectView.axis = UILayoutConstraintAxisVertical;
           self.cupIllDirectView.spacing = 1;
           self.cupIllDirectView.distribution = UIStackViewDistributionFillEqually;
           self.cupIllDirectView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.entityProfilesView addSubview:self.cupIllDirectView];
           
           NSLayoutYAxisAnchor *operationAudiencesAbsoluteRawVelocity = cupIrishView ? cupIrishView.bottomAnchor : self.entityProfilesView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.cupIllDirectView.topAnchor constraintEqualToAnchor:operationAudiencesAbsoluteRawVelocity constant:daughtersFreestyleCheckoutDiamondContainer],
               [self.cupIllDirectView.leadingAnchor constraintEqualToAnchor:self.entityProfilesView.leadingAnchor],
               [self.cupIllDirectView.trailingAnchor constraintEqualToAnchor:self.entityProfilesView.trailingAnchor],
               [self.cupIllDirectView.bottomAnchor constraintEqualToAnchor:self.entityProfilesView.bottomAnchor]
           ]];
           
           for (NSInteger i = 0; i < halfDispense.count; i++) {
               NSString *cupSerif = halfDispense[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:cupSerif forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[OutTapPlain bagOuncesColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(numeratorCap:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.cupIllDirectView addArrangedSubview:button];
           }
       }
    }
    return self;
}

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

+ (void)eventPutJapaneseMoodEraAlarm:(NSString *)title
                        message:(NSString *)message
                   halfDispense:(NSArray<NSString *> *)halfDispense
                     completion:(RepublicPreparedDownRoomDisablesEnumerate)completion {
    
    SixAlertView *mouse = [[SixAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          halfDispense:halfDispense
                                            completion:completion];
    
    
    [AwayGlyphManager.shared telephotoNameGainRatingsAskYoungerView:mouse];
    
    
    mouse.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        mouse.alpha = 1.0;
    }];
}

+ (void)eventPutJapaneseMoodEraAlarm:(NSString *)title message:(NSString *)message completion:(RepublicPreparedDownRoomDisablesEnumerate)completion {
    [self eventPutJapaneseMoodEraAlarm:title message:message halfDispense:@[OutTapPlain.loudMeterMount.awayOpt] completion:completion];
}

@end
