






#import "IcyAlertView.h"
#import "DistantEach.h"
#import "MatrixFixManager.h"
#import "Masonry.h"

#define ourCost(due) __weak typeof(due) weak##due = due;
#define deviceBed(due) __strong typeof(due) due = weak##due;

@interface IcyAlertView()

@property (nonatomic, strong) UIView *mustInvokePageView;
@property (nonatomic, copy) LatitudeDisplayCookiesLocaleMandarinMax completion;
@property (nonatomic, strong) UIStackView *funMilesEditView;

@end

@implementation IcyAlertView

- (void)dealloc {
    
}

- (instancetype)initWithFrame:(CGRect)frame
                          title:(NSString *)title
                        message:(NSString *)message
                   polarClosest:(NSArray<NSString *> *)polarClosest
                     completion:(LatitudeDisplayCookiesLocaleMandarinMax)completion {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        self.completion = completion;
        
        
        self.mustInvokePageView = [[UIView alloc] init];
        self.mustInvokePageView.backgroundColor = [DistantEach tildePastColor];
        self.mustInvokePageView.layer.cornerRadius = DistantEach.whoFrenchMin.catPointEach;
        self.mustInvokePageView.clipsToBounds = YES;
        self.mustInvokePageView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:self.mustInvokePageView];
        
        
        [NSLayoutConstraint activateConstraints:@[
            [self.mustInvokePageView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
            [self.mustInvokePageView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
            [self.mustInvokePageView.widthAnchor constraintEqualToConstant:270]
        ]];
        
        
        UIView *wetMoireView = nil;
        CGFloat rareOvulationFrontHeightSomali = 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.mustInvokePageView addSubview:titleLabel];
            
            [NSLayoutConstraint activateConstraints:@[
                [titleLabel.topAnchor constraintEqualToAnchor:self.mustInvokePageView.topAnchor constant:rareOvulationFrontHeightSomali],
                [titleLabel.leadingAnchor constraintEqualToAnchor:self.mustInvokePageView.leadingAnchor constant:16],
                [titleLabel.trailingAnchor constraintEqualToAnchor:self.mustInvokePageView.trailingAnchor constant:-16]
            ]];
            
            wetMoireView = titleLabel;
        }
        
        
        if (message.length > 0) {
            UILabel *combineLabel = [[UILabel alloc] init];
            combineLabel.text = message;
            combineLabel.textColor = UIColor.whiteColor;
            combineLabel.font = [UIFont systemFontOfSize:15];
            combineLabel.textAlignment = NSTextAlignmentCenter;
            combineLabel.numberOfLines = 0;
            combineLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.mustInvokePageView addSubview:combineLabel];
            
            NSLayoutYAxisAnchor *topAnchor = wetMoireView ? wetMoireView.bottomAnchor : self.mustInvokePageView.topAnchor;
            CGFloat pipeButYou = wetMoireView ? 10 : rareOvulationFrontHeightSomali;
            [NSLayoutConstraint activateConstraints:@[
                [combineLabel.topAnchor constraintEqualToAnchor:topAnchor constant:pipeButYou],
                [combineLabel.leadingAnchor constraintEqualToAnchor:self.mustInvokePageView.leadingAnchor constant:16],
                [combineLabel.trailingAnchor constraintEqualToAnchor:self.mustInvokePageView.trailingAnchor constant:-16]
            ]];
            wetMoireView = combineLabel;
        }
        
        
        self.funMilesEditView = [[UIStackView alloc] init];
        self.funMilesEditView.axis = UILayoutConstraintAxisVertical;
        self.funMilesEditView.spacing = 1;  
        self.funMilesEditView.distribution = UIStackViewDistributionFillEqually;
        self.funMilesEditView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.mustInvokePageView addSubview:self.funMilesEditView];
        
        
        NSLayoutYAxisAnchor *clickMicroViolationFeatMargins = wetMoireView ? wetMoireView.bottomAnchor : self.mustInvokePageView.topAnchor;
        CGFloat sortPositionPreparedPatchKelvin = wetMoireView ? rareOvulationFrontHeightSomali : rareOvulationFrontHeightSomali;
        
        [NSLayoutConstraint activateConstraints:@[
            [self.funMilesEditView.topAnchor constraintEqualToAnchor:clickMicroViolationFeatMargins constant:sortPositionPreparedPatchKelvin],
            [self.funMilesEditView.leadingAnchor constraintEqualToAnchor:self.mustInvokePageView.leadingAnchor],
            [self.funMilesEditView.trailingAnchor constraintEqualToAnchor:self.mustInvokePageView.trailingAnchor],
            [self.funMilesEditView.bottomAnchor constraintEqualToAnchor:self.mustInvokePageView.bottomAnchor]
        ]];
        
        
       
       if (polarClosest.count == 2) {
           
           self.funMilesEditView = [[UIStackView alloc] init];
           self.funMilesEditView.axis = UILayoutConstraintAxisHorizontal;
           self.funMilesEditView.distribution = UIStackViewDistributionFillEqually;
           self.funMilesEditView.spacing = 1;  
           self.funMilesEditView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.mustInvokePageView addSubview:self.funMilesEditView];
           
           NSLayoutYAxisAnchor *clickMicroViolationFeatMargins = wetMoireView ? wetMoireView.bottomAnchor : self.mustInvokePageView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.funMilesEditView.topAnchor constraintEqualToAnchor:clickMicroViolationFeatMargins constant:rareOvulationFrontHeightSomali],
               [self.funMilesEditView.leadingAnchor constraintEqualToAnchor:self.mustInvokePageView.leadingAnchor],
               [self.funMilesEditView.trailingAnchor constraintEqualToAnchor:self.mustInvokePageView.trailingAnchor],
               [self.funMilesEditView.bottomAnchor constraintEqualToAnchor:self.mustInvokePageView.bottomAnchor]
           ]];
           
           
           for (NSInteger i = 0; i < polarClosest.count; i++) {
               NSString *busStone = polarClosest[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:busStone forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[DistantEach tildePastColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(lingerPanWin:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.funMilesEditView addArrangedSubview:button];
           }
       } else {
           
           self.funMilesEditView = [[UIStackView alloc] init];
           self.funMilesEditView.axis = UILayoutConstraintAxisVertical;
           self.funMilesEditView.spacing = 1;
           self.funMilesEditView.distribution = UIStackViewDistributionFillEqually;
           self.funMilesEditView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.mustInvokePageView addSubview:self.funMilesEditView];
           
           NSLayoutYAxisAnchor *clickMicroViolationFeatMargins = wetMoireView ? wetMoireView.bottomAnchor : self.mustInvokePageView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.funMilesEditView.topAnchor constraintEqualToAnchor:clickMicroViolationFeatMargins constant:rareOvulationFrontHeightSomali],
               [self.funMilesEditView.leadingAnchor constraintEqualToAnchor:self.mustInvokePageView.leadingAnchor],
               [self.funMilesEditView.trailingAnchor constraintEqualToAnchor:self.mustInvokePageView.trailingAnchor],
               [self.funMilesEditView.bottomAnchor constraintEqualToAnchor:self.mustInvokePageView.bottomAnchor]
           ]];
           
           for (NSInteger i = 0; i < polarClosest.count; i++) {
               NSString *busStone = polarClosest[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:busStone forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[DistantEach tildePastColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(lingerPanWin:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.funMilesEditView addArrangedSubview:button];
           }
       }
    }
    return self;
}

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

+ (void)quotationCollectedPubPopSupportsMouse:(NSString *)title
                        message:(NSString *)message
                   polarClosest:(NSArray<NSString *> *)polarClosest
                     completion:(LatitudeDisplayCookiesLocaleMandarinMax)completion {
    
    IcyAlertView *fatal = [[IcyAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          polarClosest:polarClosest
                                            completion:completion];
    
    
    [MatrixFixManager.shared urgencyFocalRevisionsMixerPassiveCaseView:fatal];
    
    
    fatal.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        fatal.alpha = 1.0;
    }];
}

+ (void)quotationCollectedPubPopSupportsMouse:(NSString *)title message:(NSString *)message completion:(LatitudeDisplayCookiesLocaleMandarinMax)completion {
    [self quotationCollectedPubPopSupportsMouse:title message:message polarClosest:@[DistantEach.earMayTopModel.tension] completion:completion];
}

@end
