






#import "GetAlertView.h"
#import "MouthOunces.h"
#import "ProducingManager.h"
#import "Masonry.h"

#define tagBody(fit) __weak typeof(fit) weak##fit = fit;
#define dueInvite(fit) __strong typeof(fit) fit = weak##fit;

@interface GetAlertView()

@property (nonatomic, strong) UIView *leadOurPinGaspView;
@property (nonatomic, copy) ScopeDirectorBurmeseMidVersionHectares completion;
@property (nonatomic, strong) UIStackView *talkHandoverView;

@end

@implementation GetAlertView

- (void)dealloc {
    
}

- (instancetype)initWithFrame:(CGRect)frame
                          title:(NSString *)title
                        message:(NSString *)message
                   fetchForkJob:(NSArray<NSString *> *)fetchForkJob
                     completion:(ScopeDirectorBurmeseMidVersionHectares)completion {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        self.completion = completion;
        
        
        self.leadOurPinGaspView = [[UIView alloc] init];
        self.leadOurPinGaspView.backgroundColor = [MouthOunces syntheticColor];
        self.leadOurPinGaspView.layer.cornerRadius = MouthOunces.logTwelveEnd.lookTheInfer;
        self.leadOurPinGaspView.clipsToBounds = YES;
        self.leadOurPinGaspView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:self.leadOurPinGaspView];
        
        
        [NSLayoutConstraint activateConstraints:@[
            [self.leadOurPinGaspView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
            [self.leadOurPinGaspView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
            [self.leadOurPinGaspView.widthAnchor constraintEqualToConstant:270]
        ]];
        
        
        UIView *gigabitsView = nil;
        CGFloat blackDogNowUbiquityLegal = 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.leadOurPinGaspView addSubview:titleLabel];
            
            [NSLayoutConstraint activateConstraints:@[
                [titleLabel.topAnchor constraintEqualToAnchor:self.leadOurPinGaspView.topAnchor constant:blackDogNowUbiquityLegal],
                [titleLabel.leadingAnchor constraintEqualToAnchor:self.leadOurPinGaspView.leadingAnchor constant:16],
                [titleLabel.trailingAnchor constraintEqualToAnchor:self.leadOurPinGaspView.trailingAnchor constant:-16]
            ]];
            
            gigabitsView = titleLabel;
        }
        
        
        if (message.length > 0) {
            UILabel *menRootLabel = [[UILabel alloc] init];
            menRootLabel.text = message;
            menRootLabel.textColor = UIColor.whiteColor;
            menRootLabel.font = [UIFont systemFontOfSize:15];
            menRootLabel.textAlignment = NSTextAlignmentCenter;
            menRootLabel.numberOfLines = 0;
            menRootLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.leadOurPinGaspView addSubview:menRootLabel];
            
            NSLayoutYAxisAnchor *topAnchor = gigabitsView ? gigabitsView.bottomAnchor : self.leadOurPinGaspView.topAnchor;
            CGFloat postOffSix = gigabitsView ? 10 : blackDogNowUbiquityLegal;
            [NSLayoutConstraint activateConstraints:@[
                [menRootLabel.topAnchor constraintEqualToAnchor:topAnchor constant:postOffSix],
                [menRootLabel.leadingAnchor constraintEqualToAnchor:self.leadOurPinGaspView.leadingAnchor constant:16],
                [menRootLabel.trailingAnchor constraintEqualToAnchor:self.leadOurPinGaspView.trailingAnchor constant:-16]
            ]];
            gigabitsView = menRootLabel;
        }
        
        
        self.talkHandoverView = [[UIStackView alloc] init];
        self.talkHandoverView.axis = UILayoutConstraintAxisVertical;
        self.talkHandoverView.spacing = 1;  
        self.talkHandoverView.distribution = UIStackViewDistributionFillEqually;
        self.talkHandoverView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.leadOurPinGaspView addSubview:self.talkHandoverView];
        
        
        NSLayoutYAxisAnchor *transposeLearnedSubstringProductsItem = gigabitsView ? gigabitsView.bottomAnchor : self.leadOurPinGaspView.topAnchor;
        CGFloat seekShipmentLinkageSpouseCleanup = gigabitsView ? blackDogNowUbiquityLegal : blackDogNowUbiquityLegal;
        
        [NSLayoutConstraint activateConstraints:@[
            [self.talkHandoverView.topAnchor constraintEqualToAnchor:transposeLearnedSubstringProductsItem constant:seekShipmentLinkageSpouseCleanup],
            [self.talkHandoverView.leadingAnchor constraintEqualToAnchor:self.leadOurPinGaspView.leadingAnchor],
            [self.talkHandoverView.trailingAnchor constraintEqualToAnchor:self.leadOurPinGaspView.trailingAnchor],
            [self.talkHandoverView.bottomAnchor constraintEqualToAnchor:self.leadOurPinGaspView.bottomAnchor]
        ]];
        
        
       
       if (fetchForkJob.count == 2) {
           
           self.talkHandoverView = [[UIStackView alloc] init];
           self.talkHandoverView.axis = UILayoutConstraintAxisHorizontal;
           self.talkHandoverView.distribution = UIStackViewDistributionFillEqually;
           self.talkHandoverView.spacing = 1;  
           self.talkHandoverView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.leadOurPinGaspView addSubview:self.talkHandoverView];
           
           NSLayoutYAxisAnchor *transposeLearnedSubstringProductsItem = gigabitsView ? gigabitsView.bottomAnchor : self.leadOurPinGaspView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.talkHandoverView.topAnchor constraintEqualToAnchor:transposeLearnedSubstringProductsItem constant:blackDogNowUbiquityLegal],
               [self.talkHandoverView.leadingAnchor constraintEqualToAnchor:self.leadOurPinGaspView.leadingAnchor],
               [self.talkHandoverView.trailingAnchor constraintEqualToAnchor:self.leadOurPinGaspView.trailingAnchor],
               [self.talkHandoverView.bottomAnchor constraintEqualToAnchor:self.leadOurPinGaspView.bottomAnchor]
           ]];
           
           
           for (NSInteger i = 0; i < fetchForkJob.count; i++) {
               NSString *minStood = fetchForkJob[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:minStood forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[MouthOunces syntheticColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(edgaExcluded:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.talkHandoverView addArrangedSubview:button];
           }
       } else {
           
           self.talkHandoverView = [[UIStackView alloc] init];
           self.talkHandoverView.axis = UILayoutConstraintAxisVertical;
           self.talkHandoverView.spacing = 1;
           self.talkHandoverView.distribution = UIStackViewDistributionFillEqually;
           self.talkHandoverView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.leadOurPinGaspView addSubview:self.talkHandoverView];
           
           NSLayoutYAxisAnchor *transposeLearnedSubstringProductsItem = gigabitsView ? gigabitsView.bottomAnchor : self.leadOurPinGaspView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.talkHandoverView.topAnchor constraintEqualToAnchor:transposeLearnedSubstringProductsItem constant:blackDogNowUbiquityLegal],
               [self.talkHandoverView.leadingAnchor constraintEqualToAnchor:self.leadOurPinGaspView.leadingAnchor],
               [self.talkHandoverView.trailingAnchor constraintEqualToAnchor:self.leadOurPinGaspView.trailingAnchor],
               [self.talkHandoverView.bottomAnchor constraintEqualToAnchor:self.leadOurPinGaspView.bottomAnchor]
           ]];
           
           for (NSInteger i = 0; i < fetchForkJob.count; i++) {
               NSString *minStood = fetchForkJob[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:minStood forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[MouthOunces syntheticColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(edgaExcluded:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.talkHandoverView addArrangedSubview:button];
           }
       }
    }
    return self;
}

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

+ (void)refreshedResponsesGatheringRemainingSystemTriggers:(NSString *)title
                        message:(NSString *)message
                   fetchForkJob:(NSArray<NSString *> *)fetchForkJob
                     completion:(ScopeDirectorBurmeseMidVersionHectares)completion {
    
    GetAlertView *birth = [[GetAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          fetchForkJob:fetchForkJob
                                            completion:completion];
    
    
    [ProducingManager.shared streamedPriceBuddyAssemblyUploadingEntropyView:birth];
    
    
    birth.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        birth.alpha = 1.0;
    }];
}

+ (void)refreshedResponsesGatheringRemainingSystemTriggers:(NSString *)title message:(NSString *)message completion:(ScopeDirectorBurmeseMidVersionHectares)completion {
    [self refreshedResponsesGatheringRemainingSystemTriggers:title message:message fetchForkJob:@[MouthOunces.chatRingCharge.salient] completion:completion];
}

@end
