






#import "AreAlertView.h"
#import "RowGivenOut.h"
#import "CapUniqueManager.h"
#import "Masonry.h"

#define moveDay(egg) __weak typeof(egg) weak##egg = egg;
#define tapsAlong(egg) __strong typeof(egg) egg = weak##egg;

@interface AreAlertView()

@property (nonatomic, strong) UIView *allocateKoreanView;
@property (nonatomic, copy) DeclinedCreamyFunHashConflictDisplay completion;
@property (nonatomic, strong) UIStackView *smoothToggleView;

@end

@implementation AreAlertView

- (void)dealloc {
    
}

- (instancetype)initWithFrame:(CGRect)frame
                          title:(NSString *)title
                        message:(NSString *)message
                   toneDenseSaw:(NSArray<NSString *> *)toneDenseSaw
                     completion:(DeclinedCreamyFunHashConflictDisplay)completion {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        self.completion = completion;
        
        
        self.allocateKoreanView = [[UIView alloc] init];
        self.allocateKoreanView.backgroundColor = [RowGivenOut drainBackColor];
        self.allocateKoreanView.layer.cornerRadius = RowGivenOut.mathProxyKin.delayBinDash;
        self.allocateKoreanView.clipsToBounds = YES;
        self.allocateKoreanView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:self.allocateKoreanView];
        
        
        [NSLayoutConstraint activateConstraints:@[
            [self.allocateKoreanView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
            [self.allocateKoreanView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
            [self.allocateKoreanView.widthAnchor constraintEqualToConstant:270]
        ]];
        
        
        UIView *smartPenView = nil;
        CGFloat tryToolFallbackOnceForce = 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.allocateKoreanView addSubview:titleLabel];
            
            [NSLayoutConstraint activateConstraints:@[
                [titleLabel.topAnchor constraintEqualToAnchor:self.allocateKoreanView.topAnchor constant:tryToolFallbackOnceForce],
                [titleLabel.leadingAnchor constraintEqualToAnchor:self.allocateKoreanView.leadingAnchor constant:16],
                [titleLabel.trailingAnchor constraintEqualToAnchor:self.allocateKoreanView.trailingAnchor constant:-16]
            ]];
            
            smartPenView = titleLabel;
        }
        
        
        if (message.length > 0) {
            UILabel *mapBandLabel = [[UILabel alloc] init];
            mapBandLabel.text = message;
            mapBandLabel.textColor = UIColor.whiteColor;
            mapBandLabel.font = [UIFont systemFontOfSize:15];
            mapBandLabel.textAlignment = NSTextAlignmentCenter;
            mapBandLabel.numberOfLines = 0;
            mapBandLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.allocateKoreanView addSubview:mapBandLabel];
            
            NSLayoutYAxisAnchor *topAnchor = smartPenView ? smartPenView.bottomAnchor : self.allocateKoreanView.topAnchor;
            CGFloat fatalValue = smartPenView ? 10 : tryToolFallbackOnceForce;
            [NSLayoutConstraint activateConstraints:@[
                [mapBandLabel.topAnchor constraintEqualToAnchor:topAnchor constant:fatalValue],
                [mapBandLabel.leadingAnchor constraintEqualToAnchor:self.allocateKoreanView.leadingAnchor constant:16],
                [mapBandLabel.trailingAnchor constraintEqualToAnchor:self.allocateKoreanView.trailingAnchor constant:-16]
            ]];
            smartPenView = mapBandLabel;
        }
        
        
        self.smoothToggleView = [[UIStackView alloc] init];
        self.smoothToggleView.axis = UILayoutConstraintAxisVertical;
        self.smoothToggleView.spacing = 1;  
        self.smoothToggleView.distribution = UIStackViewDistributionFillEqually;
        self.smoothToggleView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.allocateKoreanView addSubview:self.smoothToggleView];
        
        
        NSLayoutYAxisAnchor *stackedPreventedStiffnessTheCosmic = smartPenView ? smartPenView.bottomAnchor : self.allocateKoreanView.topAnchor;
        CGFloat momentaryMeterFarAreOptional = smartPenView ? tryToolFallbackOnceForce : tryToolFallbackOnceForce;
        
        [NSLayoutConstraint activateConstraints:@[
            [self.smoothToggleView.topAnchor constraintEqualToAnchor:stackedPreventedStiffnessTheCosmic constant:momentaryMeterFarAreOptional],
            [self.smoothToggleView.leadingAnchor constraintEqualToAnchor:self.allocateKoreanView.leadingAnchor],
            [self.smoothToggleView.trailingAnchor constraintEqualToAnchor:self.allocateKoreanView.trailingAnchor],
            [self.smoothToggleView.bottomAnchor constraintEqualToAnchor:self.allocateKoreanView.bottomAnchor]
        ]];
        
        
       
       if (toneDenseSaw.count == 2) {
           
           self.smoothToggleView = [[UIStackView alloc] init];
           self.smoothToggleView.axis = UILayoutConstraintAxisHorizontal;
           self.smoothToggleView.distribution = UIStackViewDistributionFillEqually;
           self.smoothToggleView.spacing = 1;  
           self.smoothToggleView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.allocateKoreanView addSubview:self.smoothToggleView];
           
           NSLayoutYAxisAnchor *stackedPreventedStiffnessTheCosmic = smartPenView ? smartPenView.bottomAnchor : self.allocateKoreanView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.smoothToggleView.topAnchor constraintEqualToAnchor:stackedPreventedStiffnessTheCosmic constant:tryToolFallbackOnceForce],
               [self.smoothToggleView.leadingAnchor constraintEqualToAnchor:self.allocateKoreanView.leadingAnchor],
               [self.smoothToggleView.trailingAnchor constraintEqualToAnchor:self.allocateKoreanView.trailingAnchor],
               [self.smoothToggleView.bottomAnchor constraintEqualToAnchor:self.allocateKoreanView.bottomAnchor]
           ]];
           
           
           for (NSInteger i = 0; i < toneDenseSaw.count; i++) {
               NSString *proxyMix = toneDenseSaw[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:proxyMix forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[RowGivenOut drainBackColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(oddBlackLess:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.smoothToggleView addArrangedSubview:button];
           }
       } else {
           
           self.smoothToggleView = [[UIStackView alloc] init];
           self.smoothToggleView.axis = UILayoutConstraintAxisVertical;
           self.smoothToggleView.spacing = 1;
           self.smoothToggleView.distribution = UIStackViewDistributionFillEqually;
           self.smoothToggleView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.allocateKoreanView addSubview:self.smoothToggleView];
           
           NSLayoutYAxisAnchor *stackedPreventedStiffnessTheCosmic = smartPenView ? smartPenView.bottomAnchor : self.allocateKoreanView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.smoothToggleView.topAnchor constraintEqualToAnchor:stackedPreventedStiffnessTheCosmic constant:tryToolFallbackOnceForce],
               [self.smoothToggleView.leadingAnchor constraintEqualToAnchor:self.allocateKoreanView.leadingAnchor],
               [self.smoothToggleView.trailingAnchor constraintEqualToAnchor:self.allocateKoreanView.trailingAnchor],
               [self.smoothToggleView.bottomAnchor constraintEqualToAnchor:self.allocateKoreanView.bottomAnchor]
           ]];
           
           for (NSInteger i = 0; i < toneDenseSaw.count; i++) {
               NSString *proxyMix = toneDenseSaw[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:proxyMix forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[RowGivenOut drainBackColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(oddBlackLess:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.smoothToggleView addArrangedSubview:button];
           }
       }
    }
    return self;
}

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

+ (void)internalTemporalAlignZipLayeringNatural:(NSString *)title
                        message:(NSString *)message
                   toneDenseSaw:(NSArray<NSString *> *)toneDenseSaw
                     completion:(DeclinedCreamyFunHashConflictDisplay)completion {
    
    AreAlertView *loose = [[AreAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          toneDenseSaw:toneDenseSaw
                                            completion:completion];
    
    
    [CapUniqueManager.shared itsRingCommitRainWeeklyAddView:loose];
    
    
    loose.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        loose.alpha = 1.0;
    }];
}

+ (void)internalTemporalAlignZipLayeringNatural:(NSString *)title message:(NSString *)message completion:(DeclinedCreamyFunHashConflictDisplay)completion {
    [self internalTemporalAlignZipLayeringNatural:title message:message toneDenseSaw:@[RowGivenOut.nineHisSoloTen.mealTwo] completion:completion];
}

@end
