






#import "CutAlertView.h"
#import "PutBelowEye.h"
#import "StillSockManager.h"
#import "Masonry.h"

#define schemes(our) __weak typeof(our) weak##our = our;
#define ditherFit(our) __strong typeof(our) our = weak##our;

@interface CutAlertView()

@property (nonatomic, strong) UIView *squareFilmWorkView;
@property (nonatomic, copy) IssueListSuperiorsSlabClockReset completion;
@property (nonatomic, strong) UIStackView *menSunArtistView;

@end

@implementation CutAlertView

- (void)dealloc {
    
}

- (instancetype)initWithFrame:(CGRect)frame
                          title:(NSString *)title
                        message:(NSString *)message
                   exportingRun:(NSArray<NSString *> *)exportingRun
                     completion:(IssueListSuperiorsSlabClockReset)completion {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        self.completion = completion;
        
        
        self.squareFilmWorkView = [[UIView alloc] init];
        self.squareFilmWorkView.backgroundColor = [PutBelowEye charAlienColor];
        self.squareFilmWorkView.layer.cornerRadius = PutBelowEye.yetRevealHow.retryRowView;
        self.squareFilmWorkView.clipsToBounds = YES;
        self.squareFilmWorkView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:self.squareFilmWorkView];
        
        
        [NSLayoutConstraint activateConstraints:@[
            [self.squareFilmWorkView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
            [self.squareFilmWorkView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
            [self.squareFilmWorkView.widthAnchor constraintEqualToConstant:270]
        ]];
        
        
        UIView *bridgingView = nil;
        CGFloat retSyntheticGravityRoomBottom = 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.squareFilmWorkView addSubview:titleLabel];
            
            [NSLayoutConstraint activateConstraints:@[
                [titleLabel.topAnchor constraintEqualToAnchor:self.squareFilmWorkView.topAnchor constant:retSyntheticGravityRoomBottom],
                [titleLabel.leadingAnchor constraintEqualToAnchor:self.squareFilmWorkView.leadingAnchor constant:16],
                [titleLabel.trailingAnchor constraintEqualToAnchor:self.squareFilmWorkView.trailingAnchor constant:-16]
            ]];
            
            bridgingView = titleLabel;
        }
        
        
        if (message.length > 0) {
            UILabel *snapRawLabel = [[UILabel alloc] init];
            snapRawLabel.text = message;
            snapRawLabel.textColor = UIColor.whiteColor;
            snapRawLabel.font = [UIFont systemFontOfSize:15];
            snapRawLabel.textAlignment = NSTextAlignmentCenter;
            snapRawLabel.numberOfLines = 0;
            snapRawLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.squareFilmWorkView addSubview:snapRawLabel];
            
            NSLayoutYAxisAnchor *topAnchor = bridgingView ? bridgingView.bottomAnchor : self.squareFilmWorkView.topAnchor;
            CGFloat actualWork = bridgingView ? 10 : retSyntheticGravityRoomBottom;
            [NSLayoutConstraint activateConstraints:@[
                [snapRawLabel.topAnchor constraintEqualToAnchor:topAnchor constant:actualWork],
                [snapRawLabel.leadingAnchor constraintEqualToAnchor:self.squareFilmWorkView.leadingAnchor constant:16],
                [snapRawLabel.trailingAnchor constraintEqualToAnchor:self.squareFilmWorkView.trailingAnchor constant:-16]
            ]];
            bridgingView = snapRawLabel;
        }
        
        
        self.menSunArtistView = [[UIStackView alloc] init];
        self.menSunArtistView.axis = UILayoutConstraintAxisVertical;
        self.menSunArtistView.spacing = 1;  
        self.menSunArtistView.distribution = UIStackViewDistributionFillEqually;
        self.menSunArtistView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.squareFilmWorkView addSubview:self.menSunArtistView];
        
        
        NSLayoutYAxisAnchor *largestPlaceVariablesFilmExponent = bridgingView ? bridgingView.bottomAnchor : self.squareFilmWorkView.topAnchor;
        CGFloat effectiveSignRelationsProvidingPolicy = bridgingView ? retSyntheticGravityRoomBottom : retSyntheticGravityRoomBottom;
        
        [NSLayoutConstraint activateConstraints:@[
            [self.menSunArtistView.topAnchor constraintEqualToAnchor:largestPlaceVariablesFilmExponent constant:effectiveSignRelationsProvidingPolicy],
            [self.menSunArtistView.leadingAnchor constraintEqualToAnchor:self.squareFilmWorkView.leadingAnchor],
            [self.menSunArtistView.trailingAnchor constraintEqualToAnchor:self.squareFilmWorkView.trailingAnchor],
            [self.menSunArtistView.bottomAnchor constraintEqualToAnchor:self.squareFilmWorkView.bottomAnchor]
        ]];
        
        
       
       if (exportingRun.count == 2) {
           
           self.menSunArtistView = [[UIStackView alloc] init];
           self.menSunArtistView.axis = UILayoutConstraintAxisHorizontal;
           self.menSunArtistView.distribution = UIStackViewDistributionFillEqually;
           self.menSunArtistView.spacing = 1;  
           self.menSunArtistView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.squareFilmWorkView addSubview:self.menSunArtistView];
           
           NSLayoutYAxisAnchor *largestPlaceVariablesFilmExponent = bridgingView ? bridgingView.bottomAnchor : self.squareFilmWorkView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.menSunArtistView.topAnchor constraintEqualToAnchor:largestPlaceVariablesFilmExponent constant:retSyntheticGravityRoomBottom],
               [self.menSunArtistView.leadingAnchor constraintEqualToAnchor:self.squareFilmWorkView.leadingAnchor],
               [self.menSunArtistView.trailingAnchor constraintEqualToAnchor:self.squareFilmWorkView.trailingAnchor],
               [self.menSunArtistView.bottomAnchor constraintEqualToAnchor:self.squareFilmWorkView.bottomAnchor]
           ]];
           
           
           for (NSInteger i = 0; i < exportingRun.count; i++) {
               NSString *splatSex = exportingRun[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:splatSex forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[PutBelowEye charAlienColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(adjustScreen:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.menSunArtistView addArrangedSubview:button];
           }
       } else {
           
           self.menSunArtistView = [[UIStackView alloc] init];
           self.menSunArtistView.axis = UILayoutConstraintAxisVertical;
           self.menSunArtistView.spacing = 1;
           self.menSunArtistView.distribution = UIStackViewDistributionFillEqually;
           self.menSunArtistView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.squareFilmWorkView addSubview:self.menSunArtistView];
           
           NSLayoutYAxisAnchor *largestPlaceVariablesFilmExponent = bridgingView ? bridgingView.bottomAnchor : self.squareFilmWorkView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.menSunArtistView.topAnchor constraintEqualToAnchor:largestPlaceVariablesFilmExponent constant:retSyntheticGravityRoomBottom],
               [self.menSunArtistView.leadingAnchor constraintEqualToAnchor:self.squareFilmWorkView.leadingAnchor],
               [self.menSunArtistView.trailingAnchor constraintEqualToAnchor:self.squareFilmWorkView.trailingAnchor],
               [self.menSunArtistView.bottomAnchor constraintEqualToAnchor:self.squareFilmWorkView.bottomAnchor]
           ]];
           
           for (NSInteger i = 0; i < exportingRun.count; i++) {
               NSString *splatSex = exportingRun[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:splatSex forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[PutBelowEye charAlienColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(adjustScreen:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.menSunArtistView addArrangedSubview:button];
           }
       }
    }
    return self;
}

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

+ (void)execMeterSymbolLoadLoadingSide:(NSString *)title
                        message:(NSString *)message
                   exportingRun:(NSArray<NSString *> *)exportingRun
                     completion:(IssueListSuperiorsSlabClockReset)completion {
    
    CutAlertView *stair = [[CutAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          exportingRun:exportingRun
                                            completion:completion];
    
    
    [StillSockManager.shared countUsabilityNotationInfoParseFriendView:stair];
    
    
    stair.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        stair.alpha = 1.0;
    }];
}

+ (void)execMeterSymbolLoadLoadingSide:(NSString *)title message:(NSString *)message completion:(IssueListSuperiorsSlabClockReset)completion {
    [self execMeterSymbolLoadLoadingSide:title message:message exportingRun:@[PutBelowEye.listColumnRoot.scanEra] completion:completion];
}

@end
