






#import "OutAlertView.h"
#import "NapEscaping.h"
#import "ShearPeakManager.h"
#import "Masonry.h"

#define poolSon(wet) __weak typeof(wet) weak##wet = wet;
#define oneCharge(wet) __strong typeof(wet) wet = weak##wet;

@interface OutAlertView()

@property (nonatomic, strong) UIView *faxPullChatWhoView;
@property (nonatomic, copy) ArrayTerabytesCadenceCookieStreetTrack completion;
@property (nonatomic, strong) UIStackView *stormTicketsView;

@end

@implementation OutAlertView

- (void)dealloc {
    
}

- (instancetype)initWithFrame:(CGRect)frame
                          title:(NSString *)title
                        message:(NSString *)message
                   sumTooRectum:(NSArray<NSString *> *)sumTooRectum
                     completion:(ArrayTerabytesCadenceCookieStreetTrack)completion {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        self.completion = completion;
        
        
        self.faxPullChatWhoView = [[UIView alloc] init];
        self.faxPullChatWhoView.backgroundColor = [NapEscaping feedBayerColor];
        self.faxPullChatWhoView.layer.cornerRadius = NapEscaping.restoringWay.interlaceNap;
        self.faxPullChatWhoView.clipsToBounds = YES;
        self.faxPullChatWhoView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:self.faxPullChatWhoView];
        
        
        [NSLayoutConstraint activateConstraints:@[
            [self.faxPullChatWhoView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
            [self.faxPullChatWhoView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
            [self.faxPullChatWhoView.widthAnchor constraintEqualToConstant:270]
        ]];
        
        
        UIView *wrappingView = nil;
        CGFloat desktopFeaturedHomepageDustCommit = 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.faxPullChatWhoView addSubview:titleLabel];
            
            [NSLayoutConstraint activateConstraints:@[
                [titleLabel.topAnchor constraintEqualToAnchor:self.faxPullChatWhoView.topAnchor constant:desktopFeaturedHomepageDustCommit],
                [titleLabel.leadingAnchor constraintEqualToAnchor:self.faxPullChatWhoView.leadingAnchor constant:16],
                [titleLabel.trailingAnchor constraintEqualToAnchor:self.faxPullChatWhoView.trailingAnchor constant:-16]
            ]];
            
            wrappingView = titleLabel;
        }
        
        
        if (message.length > 0) {
            UILabel *fontManLabel = [[UILabel alloc] init];
            fontManLabel.text = message;
            fontManLabel.textColor = UIColor.whiteColor;
            fontManLabel.font = [UIFont systemFontOfSize:15];
            fontManLabel.textAlignment = NSTextAlignmentCenter;
            fontManLabel.numberOfLines = 0;
            fontManLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.faxPullChatWhoView addSubview:fontManLabel];
            
            NSLayoutYAxisAnchor *topAnchor = wrappingView ? wrappingView.bottomAnchor : self.faxPullChatWhoView.topAnchor;
            CGFloat withTabAdd = wrappingView ? 10 : desktopFeaturedHomepageDustCommit;
            [NSLayoutConstraint activateConstraints:@[
                [fontManLabel.topAnchor constraintEqualToAnchor:topAnchor constant:withTabAdd],
                [fontManLabel.leadingAnchor constraintEqualToAnchor:self.faxPullChatWhoView.leadingAnchor constant:16],
                [fontManLabel.trailingAnchor constraintEqualToAnchor:self.faxPullChatWhoView.trailingAnchor constant:-16]
            ]];
            wrappingView = fontManLabel;
        }
        
        
        self.stormTicketsView = [[UIStackView alloc] init];
        self.stormTicketsView.axis = UILayoutConstraintAxisVertical;
        self.stormTicketsView.spacing = 1;  
        self.stormTicketsView.distribution = UIStackViewDistributionFillEqually;
        self.stormTicketsView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.faxPullChatWhoView addSubview:self.stormTicketsView];
        
        
        NSLayoutYAxisAnchor *hasTalkUpperLargerEnabling = wrappingView ? wrappingView.bottomAnchor : self.faxPullChatWhoView.topAnchor;
        CGFloat reductionOnceSurrogateAuthorsLater = wrappingView ? desktopFeaturedHomepageDustCommit : desktopFeaturedHomepageDustCommit;
        
        [NSLayoutConstraint activateConstraints:@[
            [self.stormTicketsView.topAnchor constraintEqualToAnchor:hasTalkUpperLargerEnabling constant:reductionOnceSurrogateAuthorsLater],
            [self.stormTicketsView.leadingAnchor constraintEqualToAnchor:self.faxPullChatWhoView.leadingAnchor],
            [self.stormTicketsView.trailingAnchor constraintEqualToAnchor:self.faxPullChatWhoView.trailingAnchor],
            [self.stormTicketsView.bottomAnchor constraintEqualToAnchor:self.faxPullChatWhoView.bottomAnchor]
        ]];
        
        
       
       if (sumTooRectum.count == 2) {
           
           self.stormTicketsView = [[UIStackView alloc] init];
           self.stormTicketsView.axis = UILayoutConstraintAxisHorizontal;
           self.stormTicketsView.distribution = UIStackViewDistributionFillEqually;
           self.stormTicketsView.spacing = 1;  
           self.stormTicketsView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.faxPullChatWhoView addSubview:self.stormTicketsView];
           
           NSLayoutYAxisAnchor *hasTalkUpperLargerEnabling = wrappingView ? wrappingView.bottomAnchor : self.faxPullChatWhoView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.stormTicketsView.topAnchor constraintEqualToAnchor:hasTalkUpperLargerEnabling constant:desktopFeaturedHomepageDustCommit],
               [self.stormTicketsView.leadingAnchor constraintEqualToAnchor:self.faxPullChatWhoView.leadingAnchor],
               [self.stormTicketsView.trailingAnchor constraintEqualToAnchor:self.faxPullChatWhoView.trailingAnchor],
               [self.stormTicketsView.bottomAnchor constraintEqualToAnchor:self.faxPullChatWhoView.bottomAnchor]
           ]];
           
           
           for (NSInteger i = 0; i < sumTooRectum.count; i++) {
               NSString *tightMan = sumTooRectum[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:tightMan forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[NapEscaping feedBayerColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(brushHexTied:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.stormTicketsView addArrangedSubview:button];
           }
       } else {
           
           self.stormTicketsView = [[UIStackView alloc] init];
           self.stormTicketsView.axis = UILayoutConstraintAxisVertical;
           self.stormTicketsView.spacing = 1;
           self.stormTicketsView.distribution = UIStackViewDistributionFillEqually;
           self.stormTicketsView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.faxPullChatWhoView addSubview:self.stormTicketsView];
           
           NSLayoutYAxisAnchor *hasTalkUpperLargerEnabling = wrappingView ? wrappingView.bottomAnchor : self.faxPullChatWhoView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.stormTicketsView.topAnchor constraintEqualToAnchor:hasTalkUpperLargerEnabling constant:desktopFeaturedHomepageDustCommit],
               [self.stormTicketsView.leadingAnchor constraintEqualToAnchor:self.faxPullChatWhoView.leadingAnchor],
               [self.stormTicketsView.trailingAnchor constraintEqualToAnchor:self.faxPullChatWhoView.trailingAnchor],
               [self.stormTicketsView.bottomAnchor constraintEqualToAnchor:self.faxPullChatWhoView.bottomAnchor]
           ]];
           
           for (NSInteger i = 0; i < sumTooRectum.count; i++) {
               NSString *tightMan = sumTooRectum[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:tightMan forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[NapEscaping feedBayerColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(brushHexTied:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.stormTicketsView addArrangedSubview:button];
           }
       }
    }
    return self;
}

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

+ (void)remembersFarsiAbsentDetectionFormInstant:(NSString *)title
                        message:(NSString *)message
                   sumTooRectum:(NSArray<NSString *> *)sumTooRectum
                     completion:(ArrayTerabytesCadenceCookieStreetTrack)completion {
    
    OutAlertView *tilde = [[OutAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          sumTooRectum:sumTooRectum
                                            completion:completion];
    
    
    [ShearPeakManager.shared permanentPasswordsNiacinAvailBannerExceedsView:tilde];
    
    
    tilde.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        tilde.alpha = 1.0;
    }];
}

+ (void)remembersFarsiAbsentDetectionFormInstant:(NSString *)title message:(NSString *)message completion:(ArrayTerabytesCadenceCookieStreetTrack)completion {
    [self remembersFarsiAbsentDetectionFormInstant:title message:message sumTooRectum:@[NapEscaping.sigmaTabBedKit.tagsMay] completion:completion];
}

@end
