






#import "TenAlertView.h"
#import "ReadWaxDash.h"
#import "StandCapsManager.h"
#import "Masonry.h"

#define seeUsed(kin) __weak typeof(kin) weak##kin = kin;
#define scalarNow(kin) __strong typeof(kin) kin = weak##kin;

@interface TenAlertView()

@property (nonatomic, strong) UIView *andHeapPrepTheView;
@property (nonatomic, copy) WithinDecomposeTrackCallbacksWonRedirect completion;
@property (nonatomic, strong) UIStackView *tooRouteCurlView;

@end

@implementation TenAlertView

- (void)dealloc {
    
}

- (instancetype)initWithFrame:(CGRect)frame
                          title:(NSString *)title
                        message:(NSString *)message
                   pinchPublish:(NSArray<NSString *> *)pinchPublish
                     completion:(WithinDecomposeTrackCallbacksWonRedirect)completion {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        self.completion = completion;
        
        
        self.andHeapPrepTheView = [[UIView alloc] init];
        self.andHeapPrepTheView.backgroundColor = [ReadWaxDash trackForkColor];
        self.andHeapPrepTheView.layer.cornerRadius = ReadWaxDash.strideFooter.faxReverting;
        self.andHeapPrepTheView.clipsToBounds = YES;
        self.andHeapPrepTheView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:self.andHeapPrepTheView];
        
        
        [NSLayoutConstraint activateConstraints:@[
            [self.andHeapPrepTheView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
            [self.andHeapPrepTheView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
            [self.andHeapPrepTheView.widthAnchor constraintEqualToConstant:270]
        ]];
        
        
        UIView *quietPinView = nil;
        CGFloat nominalIncorrectEggArmenianBlob = 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.andHeapPrepTheView addSubview:titleLabel];
            
            [NSLayoutConstraint activateConstraints:@[
                [titleLabel.topAnchor constraintEqualToAnchor:self.andHeapPrepTheView.topAnchor constant:nominalIncorrectEggArmenianBlob],
                [titleLabel.leadingAnchor constraintEqualToAnchor:self.andHeapPrepTheView.leadingAnchor constant:16],
                [titleLabel.trailingAnchor constraintEqualToAnchor:self.andHeapPrepTheView.trailingAnchor constant:-16]
            ]];
            
            quietPinView = titleLabel;
        }
        
        
        if (message.length > 0) {
            UILabel *flushedLabel = [[UILabel alloc] init];
            flushedLabel.text = message;
            flushedLabel.textColor = UIColor.whiteColor;
            flushedLabel.font = [UIFont systemFontOfSize:15];
            flushedLabel.textAlignment = NSTextAlignmentCenter;
            flushedLabel.numberOfLines = 0;
            flushedLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.andHeapPrepTheView addSubview:flushedLabel];
            
            NSLayoutYAxisAnchor *topAnchor = quietPinView ? quietPinView.bottomAnchor : self.andHeapPrepTheView.topAnchor;
            CGFloat sugarAlong = quietPinView ? 10 : nominalIncorrectEggArmenianBlob;
            [NSLayoutConstraint activateConstraints:@[
                [flushedLabel.topAnchor constraintEqualToAnchor:topAnchor constant:sugarAlong],
                [flushedLabel.leadingAnchor constraintEqualToAnchor:self.andHeapPrepTheView.leadingAnchor constant:16],
                [flushedLabel.trailingAnchor constraintEqualToAnchor:self.andHeapPrepTheView.trailingAnchor constant:-16]
            ]];
            quietPinView = flushedLabel;
        }
        
        
        self.tooRouteCurlView = [[UIStackView alloc] init];
        self.tooRouteCurlView.axis = UILayoutConstraintAxisVertical;
        self.tooRouteCurlView.spacing = 1;  
        self.tooRouteCurlView.distribution = UIStackViewDistributionFillEqually;
        self.tooRouteCurlView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.andHeapPrepTheView addSubview:self.tooRouteCurlView];
        
        
        NSLayoutYAxisAnchor *providerAddTemplateFilteringShutter = quietPinView ? quietPinView.bottomAnchor : self.andHeapPrepTheView.topAnchor;
        CGFloat memoryFrontWorkflowSupplyUnify = quietPinView ? nominalIncorrectEggArmenianBlob : nominalIncorrectEggArmenianBlob;
        
        [NSLayoutConstraint activateConstraints:@[
            [self.tooRouteCurlView.topAnchor constraintEqualToAnchor:providerAddTemplateFilteringShutter constant:memoryFrontWorkflowSupplyUnify],
            [self.tooRouteCurlView.leadingAnchor constraintEqualToAnchor:self.andHeapPrepTheView.leadingAnchor],
            [self.tooRouteCurlView.trailingAnchor constraintEqualToAnchor:self.andHeapPrepTheView.trailingAnchor],
            [self.tooRouteCurlView.bottomAnchor constraintEqualToAnchor:self.andHeapPrepTheView.bottomAnchor]
        ]];
        
        
       
       if (pinchPublish.count == 2) {
           
           self.tooRouteCurlView = [[UIStackView alloc] init];
           self.tooRouteCurlView.axis = UILayoutConstraintAxisHorizontal;
           self.tooRouteCurlView.distribution = UIStackViewDistributionFillEqually;
           self.tooRouteCurlView.spacing = 1;  
           self.tooRouteCurlView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.andHeapPrepTheView addSubview:self.tooRouteCurlView];
           
           NSLayoutYAxisAnchor *providerAddTemplateFilteringShutter = quietPinView ? quietPinView.bottomAnchor : self.andHeapPrepTheView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.tooRouteCurlView.topAnchor constraintEqualToAnchor:providerAddTemplateFilteringShutter constant:nominalIncorrectEggArmenianBlob],
               [self.tooRouteCurlView.leadingAnchor constraintEqualToAnchor:self.andHeapPrepTheView.leadingAnchor],
               [self.tooRouteCurlView.trailingAnchor constraintEqualToAnchor:self.andHeapPrepTheView.trailingAnchor],
               [self.tooRouteCurlView.bottomAnchor constraintEqualToAnchor:self.andHeapPrepTheView.bottomAnchor]
           ]];
           
           
           for (NSInteger i = 0; i < pinchPublish.count; i++) {
               NSString *pivotTab = pinchPublish[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:pivotTab forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[ReadWaxDash trackForkColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(behaveDryWon:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.tooRouteCurlView addArrangedSubview:button];
           }
       } else {
           
           self.tooRouteCurlView = [[UIStackView alloc] init];
           self.tooRouteCurlView.axis = UILayoutConstraintAxisVertical;
           self.tooRouteCurlView.spacing = 1;
           self.tooRouteCurlView.distribution = UIStackViewDistributionFillEqually;
           self.tooRouteCurlView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.andHeapPrepTheView addSubview:self.tooRouteCurlView];
           
           NSLayoutYAxisAnchor *providerAddTemplateFilteringShutter = quietPinView ? quietPinView.bottomAnchor : self.andHeapPrepTheView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.tooRouteCurlView.topAnchor constraintEqualToAnchor:providerAddTemplateFilteringShutter constant:nominalIncorrectEggArmenianBlob],
               [self.tooRouteCurlView.leadingAnchor constraintEqualToAnchor:self.andHeapPrepTheView.leadingAnchor],
               [self.tooRouteCurlView.trailingAnchor constraintEqualToAnchor:self.andHeapPrepTheView.trailingAnchor],
               [self.tooRouteCurlView.bottomAnchor constraintEqualToAnchor:self.andHeapPrepTheView.bottomAnchor]
           ]];
           
           for (NSInteger i = 0; i < pinchPublish.count; i++) {
               NSString *pivotTab = pinchPublish[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:pivotTab forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[ReadWaxDash trackForkColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(behaveDryWon:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.tooRouteCurlView addArrangedSubview:button];
           }
       }
    }
    return self;
}

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

+ (void)unlockLocalizedExistingStructureManagedTab:(NSString *)title
                        message:(NSString *)message
                   pinchPublish:(NSArray<NSString *> *)pinchPublish
                     completion:(WithinDecomposeTrackCallbacksWonRedirect)completion {
    
    TenAlertView *arrow = [[TenAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          pinchPublish:pinchPublish
                                            completion:completion];
    
    
    [StandCapsManager.shared iterateFaceOffSawReportingLighterView:arrow];
    
    
    arrow.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        arrow.alpha = 1.0;
    }];
}

+ (void)unlockLocalizedExistingStructureManagedTab:(NSString *)title message:(NSString *)message completion:(WithinDecomposeTrackCallbacksWonRedirect)completion {
    [self unlockLocalizedExistingStructureManagedTab:title message:message pinchPublish:@[ReadWaxDash.spaLiveIronTry.ageWarn] completion:completion];
}

@end
