






#import "HexAlertView.h"
#import "LawExported.h"
#import "BeaconAskManager.h"
#import "Masonry.h"

#define ropePan(who) __weak typeof(who) weak##who = who;
#define tremorTap(who) __strong typeof(who) who = weak##who;

@interface HexAlertView()

@property (nonatomic, strong) UIView *explicitMarginView;
@property (nonatomic, copy) ScriptsPaymentsMemoryAscendingPacketsShadow completion;
@property (nonatomic, strong) UIStackView *matchSlabEraView;

@end

@implementation HexAlertView

- (void)dealloc {
    
}

- (instancetype)initWithFrame:(CGRect)frame
                          title:(NSString *)title
                        message:(NSString *)message
                   pubContinued:(NSArray<NSString *> *)pubContinued
                     completion:(ScriptsPaymentsMemoryAscendingPacketsShadow)completion {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        self.completion = completion;
        
        
        self.explicitMarginView = [[UIView alloc] init];
        self.explicitMarginView.backgroundColor = [LawExported specifierColor];
        self.explicitMarginView.layer.cornerRadius = 8.0;
        self.explicitMarginView.clipsToBounds = YES;
        self.explicitMarginView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:self.explicitMarginView];
        
        
        [NSLayoutConstraint activateConstraints:@[
            [self.explicitMarginView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
            [self.explicitMarginView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
            [self.explicitMarginView.widthAnchor constraintEqualToConstant:270]
        ]];
        
        
        UIView *externalView = nil;
        CGFloat sobStriationEntryHandlerOverall = 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.explicitMarginView addSubview:titleLabel];
            
            [NSLayoutConstraint activateConstraints:@[
                [titleLabel.topAnchor constraintEqualToAnchor:self.explicitMarginView.topAnchor constant:sobStriationEntryHandlerOverall],
                [titleLabel.leadingAnchor constraintEqualToAnchor:self.explicitMarginView.leadingAnchor constant:16],
                [titleLabel.trailingAnchor constraintEqualToAnchor:self.explicitMarginView.trailingAnchor constant:-16]
            ]];
            
            externalView = titleLabel;
        }
        
        
        if (message.length > 0) {
            UILabel *blobBedLabel = [[UILabel alloc] init];
            blobBedLabel.text = message;
            blobBedLabel.textColor = UIColor.whiteColor;
            blobBedLabel.font = [UIFont systemFontOfSize:15];
            blobBedLabel.textAlignment = NSTextAlignmentCenter;
            blobBedLabel.numberOfLines = 0;
            blobBedLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.explicitMarginView addSubview:blobBedLabel];
            
            NSLayoutYAxisAnchor *topAnchor = externalView ? externalView.bottomAnchor : self.explicitMarginView.topAnchor;
            CGFloat duplexNone = externalView ? 10 : sobStriationEntryHandlerOverall;
            [NSLayoutConstraint activateConstraints:@[
                [blobBedLabel.topAnchor constraintEqualToAnchor:topAnchor constant:duplexNone],
                [blobBedLabel.leadingAnchor constraintEqualToAnchor:self.explicitMarginView.leadingAnchor constant:16],
                [blobBedLabel.trailingAnchor constraintEqualToAnchor:self.explicitMarginView.trailingAnchor constant:-16]
            ]];
            externalView = blobBedLabel;
        }
        
        
        self.matchSlabEraView = [[UIStackView alloc] init];
        self.matchSlabEraView.axis = UILayoutConstraintAxisVertical;
        self.matchSlabEraView.spacing = 1;  
        self.matchSlabEraView.distribution = UIStackViewDistributionFillEqually;
        self.matchSlabEraView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.explicitMarginView addSubview:self.matchSlabEraView];
        
        
        NSLayoutYAxisAnchor *linerActivityPingFlippedOnce = externalView ? externalView.bottomAnchor : self.explicitMarginView.topAnchor;
        CGFloat unsavedJustifiedApplySendGasp = externalView ? sobStriationEntryHandlerOverall : sobStriationEntryHandlerOverall;
        
        [NSLayoutConstraint activateConstraints:@[
            [self.matchSlabEraView.topAnchor constraintEqualToAnchor:linerActivityPingFlippedOnce constant:unsavedJustifiedApplySendGasp],
            [self.matchSlabEraView.leadingAnchor constraintEqualToAnchor:self.explicitMarginView.leadingAnchor],
            [self.matchSlabEraView.trailingAnchor constraintEqualToAnchor:self.explicitMarginView.trailingAnchor],
            [self.matchSlabEraView.bottomAnchor constraintEqualToAnchor:self.explicitMarginView.bottomAnchor]
        ]];
        
        
       
       if (pubContinued.count == 2) {
           
           self.matchSlabEraView = [[UIStackView alloc] init];
           self.matchSlabEraView.axis = UILayoutConstraintAxisHorizontal;
           self.matchSlabEraView.distribution = UIStackViewDistributionFillEqually;
           self.matchSlabEraView.spacing = 1;  
           self.matchSlabEraView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.explicitMarginView addSubview:self.matchSlabEraView];
           
           NSLayoutYAxisAnchor *linerActivityPingFlippedOnce = externalView ? externalView.bottomAnchor : self.explicitMarginView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.matchSlabEraView.topAnchor constraintEqualToAnchor:linerActivityPingFlippedOnce constant:sobStriationEntryHandlerOverall],
               [self.matchSlabEraView.leadingAnchor constraintEqualToAnchor:self.explicitMarginView.leadingAnchor],
               [self.matchSlabEraView.trailingAnchor constraintEqualToAnchor:self.explicitMarginView.trailingAnchor],
               [self.matchSlabEraView.bottomAnchor constraintEqualToAnchor:self.explicitMarginView.bottomAnchor]
           ]];
           
           
           for (NSInteger i = 0; i < pubContinued.count; i++) {
               NSString *bringTag = pubContinued[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:bringTag forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[LawExported specifierColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(withinMinute:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.matchSlabEraView addArrangedSubview:button];
           }
       } else {
           
           self.matchSlabEraView = [[UIStackView alloc] init];
           self.matchSlabEraView.axis = UILayoutConstraintAxisVertical;
           self.matchSlabEraView.spacing = 1;
           self.matchSlabEraView.distribution = UIStackViewDistributionFillEqually;
           self.matchSlabEraView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.explicitMarginView addSubview:self.matchSlabEraView];
           
           NSLayoutYAxisAnchor *linerActivityPingFlippedOnce = externalView ? externalView.bottomAnchor : self.explicitMarginView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.matchSlabEraView.topAnchor constraintEqualToAnchor:linerActivityPingFlippedOnce constant:sobStriationEntryHandlerOverall],
               [self.matchSlabEraView.leadingAnchor constraintEqualToAnchor:self.explicitMarginView.leadingAnchor],
               [self.matchSlabEraView.trailingAnchor constraintEqualToAnchor:self.explicitMarginView.trailingAnchor],
               [self.matchSlabEraView.bottomAnchor constraintEqualToAnchor:self.explicitMarginView.bottomAnchor]
           ]];
           
           for (NSInteger i = 0; i < pubContinued.count; i++) {
               NSString *bringTag = pubContinued[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:bringTag forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[LawExported specifierColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(withinMinute:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.matchSlabEraView addArrangedSubview:button];
           }
       }
    }
    return self;
}

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

+ (void)playThemeHindiHandledFormOptional:(NSString *)title
                        message:(NSString *)message
                   pubContinued:(NSArray<NSString *> *)pubContinued
                     completion:(ScriptsPaymentsMemoryAscendingPacketsShadow)completion {
    
    HexAlertView *trash = [[HexAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          pubContinued:pubContinued
                                            completion:completion];
    
    
    [BeaconAskManager.shared behaviorsCutRepeatDetectsFootballPreservesView:trash];
    
    
    trash.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        trash.alpha = 1.0;
    }];
}

+ (void)playThemeHindiHandledFormOptional:(NSString *)title message:(NSString *)message completion:(ScriptsPaymentsMemoryAscendingPacketsShadow)completion {
    [self playThemeHindiHandledFormOptional:title message:message pubContinued:@[LawExported.valueOutArtMen.lawSkin] completion:completion];
}

@end
