






#import "HerAlertView.h"
#import "SubBondFour.h"
#import "KeysVoiceManager.h"
#import "Masonry.h"

#define paceBig(son) __weak typeof(son) weak##son = son;
#define buildRule(son) __strong typeof(son) son = weak##son;

@interface HerAlertView()

@property (nonatomic, strong) UIView *recordedEditorView;
@property (nonatomic, copy) CollectedGaussianExchangesSmileCollectSemantic completion;
@property (nonatomic, strong) UIStackView *hueTelephoneView;

@end

@implementation HerAlertView

- (void)dealloc {
    
}

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

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

+ (void)peakKilohertzRepeatsModerateCaretIntent:(NSString *)title
                        message:(NSString *)message
                   softItsBuddy:(NSArray<NSString *> *)softItsBuddy
                     completion:(CollectedGaussianExchangesSmileCollectSemantic)completion {
    
    HerAlertView *white = [[HerAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          softItsBuddy:softItsBuddy
                                            completion:completion];
    
    
    [KeysVoiceManager.shared runAlternateEarlierFunctionsRemainingRotorView:white];
    
    
    white.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        white.alpha = 1.0;
    }];
}

+ (void)peakKilohertzRepeatsModerateCaretIntent:(NSString *)title message:(NSString *)message completion:(CollectedGaussianExchangesSmileCollectSemantic)completion {
    [self peakKilohertzRepeatsModerateCaretIntent:title message:message softItsBuddy:@[SubBondFour.injectionBlack.rearRet] completion:completion];
}

@end
