






#import "EndAlertView.h"
#import "ApplyToggle.h"
#import "CombiningManager.h"
#import "Masonry.h"

#define theGain(opt) __weak typeof(opt) weak##opt = opt;
#define vowelFile(opt) __strong typeof(opt) opt = weak##opt;

@interface EndAlertView()

@property (nonatomic, strong) UIView *sixWayHitSlideView;
@property (nonatomic, copy) LocatorRetainEchoItalianHangTamil completion;
@property (nonatomic, strong) UIStackView *bevelBitViewView;

@end

@implementation EndAlertView

- (void)dealloc {
    
}

- (instancetype)initWithFrame:(CGRect)frame
                          title:(NSString *)title
                        message:(NSString *)message
                   collapsesIll:(NSArray<NSString *> *)collapsesIll
                     completion:(LocatorRetainEchoItalianHangTamil)completion {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        self.completion = completion;
        
        
        self.sixWayHitSlideView = [[UIView alloc] init];
        self.sixWayHitSlideView.backgroundColor = [ApplyToggle dueMethodColor];
        self.sixWayHitSlideView.layer.cornerRadius = ApplyToggle.findSwipeOur.twoMenuShare;
        self.sixWayHitSlideView.clipsToBounds = YES;
        self.sixWayHitSlideView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:self.sixWayHitSlideView];
        
        
        [NSLayoutConstraint activateConstraints:@[
            [self.sixWayHitSlideView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
            [self.sixWayHitSlideView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
            [self.sixWayHitSlideView.widthAnchor constraintEqualToConstant:270]
        ]];
        
        
        UIView *hisExitsView = nil;
        CGFloat yahooBalticAnotherTapsMostly = 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.sixWayHitSlideView addSubview:titleLabel];
            
            [NSLayoutConstraint activateConstraints:@[
                [titleLabel.topAnchor constraintEqualToAnchor:self.sixWayHitSlideView.topAnchor constant:yahooBalticAnotherTapsMostly],
                [titleLabel.leadingAnchor constraintEqualToAnchor:self.sixWayHitSlideView.leadingAnchor constant:16],
                [titleLabel.trailingAnchor constraintEqualToAnchor:self.sixWayHitSlideView.trailingAnchor constant:-16]
            ]];
            
            hisExitsView = titleLabel;
        }
        
        
        if (message.length > 0) {
            UILabel *fatHostLabel = [[UILabel alloc] init];
            fatHostLabel.text = message;
            fatHostLabel.textColor = UIColor.whiteColor;
            fatHostLabel.font = [UIFont systemFontOfSize:15];
            fatHostLabel.textAlignment = NSTextAlignmentCenter;
            fatHostLabel.numberOfLines = 0;
            fatHostLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.sixWayHitSlideView addSubview:fatHostLabel];
            
            NSLayoutYAxisAnchor *topAnchor = hisExitsView ? hisExitsView.bottomAnchor : self.sixWayHitSlideView.topAnchor;
            CGFloat useHitRead = hisExitsView ? 10 : yahooBalticAnotherTapsMostly;
            [NSLayoutConstraint activateConstraints:@[
                [fatHostLabel.topAnchor constraintEqualToAnchor:topAnchor constant:useHitRead],
                [fatHostLabel.leadingAnchor constraintEqualToAnchor:self.sixWayHitSlideView.leadingAnchor constant:16],
                [fatHostLabel.trailingAnchor constraintEqualToAnchor:self.sixWayHitSlideView.trailingAnchor constant:-16]
            ]];
            hisExitsView = fatHostLabel;
        }
        
        
        self.bevelBitViewView = [[UIStackView alloc] init];
        self.bevelBitViewView.axis = UILayoutConstraintAxisVertical;
        self.bevelBitViewView.spacing = 1;  
        self.bevelBitViewView.distribution = UIStackViewDistributionFillEqually;
        self.bevelBitViewView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.sixWayHitSlideView addSubview:self.bevelBitViewView];
        
        
        NSLayoutYAxisAnchor *transportLoudOldestIllVariables = hisExitsView ? hisExitsView.bottomAnchor : self.sixWayHitSlideView.topAnchor;
        CGFloat seventeenRecordingStartupStartingToo = hisExitsView ? yahooBalticAnotherTapsMostly : yahooBalticAnotherTapsMostly;
        
        [NSLayoutConstraint activateConstraints:@[
            [self.bevelBitViewView.topAnchor constraintEqualToAnchor:transportLoudOldestIllVariables constant:seventeenRecordingStartupStartingToo],
            [self.bevelBitViewView.leadingAnchor constraintEqualToAnchor:self.sixWayHitSlideView.leadingAnchor],
            [self.bevelBitViewView.trailingAnchor constraintEqualToAnchor:self.sixWayHitSlideView.trailingAnchor],
            [self.bevelBitViewView.bottomAnchor constraintEqualToAnchor:self.sixWayHitSlideView.bottomAnchor]
        ]];
        
        
       
       if (collapsesIll.count == 2) {
           
           self.bevelBitViewView = [[UIStackView alloc] init];
           self.bevelBitViewView.axis = UILayoutConstraintAxisHorizontal;
           self.bevelBitViewView.distribution = UIStackViewDistributionFillEqually;
           self.bevelBitViewView.spacing = 1;  
           self.bevelBitViewView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.sixWayHitSlideView addSubview:self.bevelBitViewView];
           
           NSLayoutYAxisAnchor *transportLoudOldestIllVariables = hisExitsView ? hisExitsView.bottomAnchor : self.sixWayHitSlideView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.bevelBitViewView.topAnchor constraintEqualToAnchor:transportLoudOldestIllVariables constant:yahooBalticAnotherTapsMostly],
               [self.bevelBitViewView.leadingAnchor constraintEqualToAnchor:self.sixWayHitSlideView.leadingAnchor],
               [self.bevelBitViewView.trailingAnchor constraintEqualToAnchor:self.sixWayHitSlideView.trailingAnchor],
               [self.bevelBitViewView.bottomAnchor constraintEqualToAnchor:self.sixWayHitSlideView.bottomAnchor]
           ]];
           
           
           for (NSInteger i = 0; i < collapsesIll.count; i++) {
               NSString *peerLogo = collapsesIll[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:peerLogo forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[ApplyToggle dueMethodColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(darkCaretRun:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.bevelBitViewView addArrangedSubview:button];
           }
       } else {
           
           self.bevelBitViewView = [[UIStackView alloc] init];
           self.bevelBitViewView.axis = UILayoutConstraintAxisVertical;
           self.bevelBitViewView.spacing = 1;
           self.bevelBitViewView.distribution = UIStackViewDistributionFillEqually;
           self.bevelBitViewView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.sixWayHitSlideView addSubview:self.bevelBitViewView];
           
           NSLayoutYAxisAnchor *transportLoudOldestIllVariables = hisExitsView ? hisExitsView.bottomAnchor : self.sixWayHitSlideView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.bevelBitViewView.topAnchor constraintEqualToAnchor:transportLoudOldestIllVariables constant:yahooBalticAnotherTapsMostly],
               [self.bevelBitViewView.leadingAnchor constraintEqualToAnchor:self.sixWayHitSlideView.leadingAnchor],
               [self.bevelBitViewView.trailingAnchor constraintEqualToAnchor:self.sixWayHitSlideView.trailingAnchor],
               [self.bevelBitViewView.bottomAnchor constraintEqualToAnchor:self.sixWayHitSlideView.bottomAnchor]
           ]];
           
           for (NSInteger i = 0; i < collapsesIll.count; i++) {
               NSString *peerLogo = collapsesIll[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:peerLogo forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[ApplyToggle dueMethodColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(darkCaretRun:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.bevelBitViewView addArrangedSubview:button];
           }
       }
    }
    return self;
}

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

+ (void)effectiveWorkingMidOperandResizeHidden:(NSString *)title
                        message:(NSString *)message
                   collapsesIll:(NSArray<NSString *> *)collapsesIll
                     completion:(LocatorRetainEchoItalianHangTamil)completion {
    
    EndAlertView *solve = [[EndAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          collapsesIll:collapsesIll
                                            completion:completion];
    
    
    [CombiningManager.shared activatedLighterAliveAxesLetterSecureView:solve];
    
    
    solve.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        solve.alpha = 1.0;
    }];
}

+ (void)effectiveWorkingMidOperandResizeHidden:(NSString *)title message:(NSString *)message completion:(LocatorRetainEchoItalianHangTamil)completion {
    [self effectiveWorkingMidOperandResizeHidden:title message:message collapsesIll:@[ApplyToggle.subDayEventDay.earOnly] completion:completion];
}

@end
