








#import "HertzLocalizes.h"

#define BevelWillLive self.frame.size.width

@interface HertzLocalizes()



@property (nonatomic, strong) NSMutableArray                            *illRoleArray;



@property (nonatomic, strong) NSMutableArray <TryBigWarnCubeCell *>      *wakeArray;



@property (strong, nonatomic) NSMutableArray <TryBigWarnCubeCell *>      *panTintPolar;



@property (assign, nonatomic) NSInteger                                 count;



@property (nonatomic, assign) PlayBaseballDeferringTakeFun                          status;



@property (nonatomic, assign) NSInteger                                 channelCount;



@property (nonatomic, assign) CGFloat                                   online;

@end

@implementation HertzLocalizes

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.status = EarlyStrokedAudiencesOptionWaxLayer;
    }
    return self;
}

- (void)airFragments
{
    
    if (self.wakeArray.firstObject) {
        
        
        TryBigWarnCubeCell *latvianView = self.wakeArray.firstObject;
        
        latvianView.frame = CGRectMake(BevelWillLive, 0, latvianView.skinSaySize.width, latvianView.skinSaySize.height);
        
        self.online = latvianView.online;
        
        self.channelCount = latvianView.channelCount;
        
        
        NSInteger row = [self transferSonEldestSoftnessHeightAutoImmutable:latvianView];
        
        
        if (row >= 0) {
            
            
            [self.wakeArray removeObjectAtIndex:0];
            
            
            if (![self.subviews containsObject:latvianView]) {
                [self addSubview:latvianView];
            }
            latvianView.frame = CGRectMake(BevelWillLive,  row * (latvianView.skinSaySize.height + _online), latvianView.skinSaySize.width, latvianView.skinSaySize.height);
            
            
            [_illRoleArray setObject:latvianView atIndexedSubscript:row];
            
            
            if ([self.delegate respondsToSelector:@selector(mixWalkAlarmView:willDisplayCell:)]) {
                [self.delegate mixWalkAlarmView:self willDisplayCell:latvianView];
            }
            
            
            [self.panTintPolar addObject:latvianView];
            
            [latvianView discountsPlayableLocalizesAngleTatar:^{
                
                
                [latvianView setTransform:CGAffineTransformMakeTranslation(- latvianView.frame.size.width-BevelWillLive, 0)];
                
            } completion:^(BOOL finished) {
                
                [latvianView removeFromSuperview];
                
                
                [self.panTintPolar removeObject:latvianView];
                
                
                if ([self.delegate respondsToSelector:@selector(mixWalkAlarmView:didEndDisplayingCell:)]) {
                    [self.delegate mixWalkAlarmView:self didEndDisplayingCell:latvianView];
                }
                
                
                if (--self.count <= 0) {
                    if ([self.delegate respondsToSelector:@selector(rankedRadixButHintPickSpeakersButtonDog:)]) {
                        [self.delegate rankedRadixButHintPickSpeakersButtonDog:self];
                    }
                    self.count = 0;
                }
                
                

            }];
        }
    }
    
    [self performSelector:@selector(airFragments) withObject:nil afterDelay:0.45f];
}


- (void)oldCarCarBring:(NSArray <TryBigWarnCubeCell *> *)barrages
{
    self.count += barrages.count;
    [self.wakeArray addObjectsFromArray:barrages];
}

- (void)start
{
    if (self.status == LocalInjectionSemanticsEmergencyReceivedThirteen) {
        return;
    }
    self.status = LocalInjectionSemanticsEmergencyReceivedThirteen;
    
    [self airFragments];
}

- (void)stop
{
    if (self.status == EarlyStrokedAudiencesOptionWaxLayer) {
        return;
    }
    self.status = EarlyStrokedAudiencesOptionWaxLayer;
    
    if (self.panTintPolar.count) {
        [self.panTintPolar makeObjectsPerformSelector:@selector(pause)];
    }
    
    if (self.wakeArray.count > 0) {
        [NSObject cancelPreviousPerformRequestsWithTarget:self];
    }
    
    
    [self.panTintPolar  makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.channelCount       = 0;
    self.count              = 0;
    [self.panTintPolar  removeAllObjects];
    [self.wakeArray     removeAllObjects];
    [self.illRoleArray  removeAllObjects];
    
    self.panTintPolar       = nil;
    self.wakeArray          = nil;
    self.illRoleArray       = nil;
}


- (NSInteger)transferSonEldestSoftnessHeightAutoImmutable:(TryBigWarnCubeCell *)newBarrage
{
    for (int row = 0; row<_illRoleArray.count; row++) {
        NSObject *object = _illRoleArray[row];
        if ([object isKindOfClass:[NSNumber class]]) { 
            
            return row;
            
        }else if ([object isKindOfClass:[TryBigWarnCubeCell class]]) { 
            
            TryBigWarnCubeCell *uighurFlow = (TryBigWarnCubeCell*)object;
            
            if ([self transferSonEldestSoftnessHeightAutoImmutable:uighurFlow invertOpt:newBarrage]) {
                
                return row;
            }
        }
    }
    
    return -1;
}


- (BOOL)transferSonEldestSoftnessHeightAutoImmutable:(TryBigWarnCubeCell *)uighurFlow invertOpt:(TryBigWarnCubeCell *)newBarrage
{
    
    if (uighurFlow.status == TapEyeSoloReaderGracefulAudiences) {
        return NO;
    }
    
    
    CGRect rect = [uighurFlow.layer.presentationLayer frame];
    if (rect.origin.x>BevelWillLive - uighurFlow.frame.size.width) {
        
        return NO;
    }else if (rect.size.width == 0)
    {
        
        return NO;
    }
    else if (uighurFlow.frame.size.width > newBarrage.frame.size.width) {
        
        return YES;
    }else
    {
        
        CGFloat time = BevelWillLive/(BevelWillLive+newBarrage.frame.size.width)*newBarrage.coverEastAny;
        
        CGFloat gray = rect.origin.x - time/(uighurFlow.coverEastAny)*(BevelWillLive + uighurFlow.frame.size.width);
        if (gray < -uighurFlow.frame.size.width) {
            
            return YES;
        }
    }
    return NO;
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    UITouch *smile = [touches anyObject];
    CGPoint pullBehave  = [smile locationInView:self];
    for (TryBigWarnCubeCell *latvianView in [self subviews])
    {
        if ([latvianView.layer.presentationLayer hitTest:pullBehave])
        {
            
            if ([self.delegate respondsToSelector:@selector(mixWalkAlarmView:nodeCheckedCell:)]) {
                [self.delegate mixWalkAlarmView:self nodeCheckedCell:latvianView];
            }
            break;
        }
    }
}




- (NSMutableArray<TryBigWarnCubeCell *> *)wakeArray {
    if (!_wakeArray) {
        _wakeArray = [[NSMutableArray alloc] init];
    }
    return _wakeArray;
}


- (NSMutableArray<TryBigWarnCubeCell *> *)panTintPolar {
    if (!_panTintPolar) {
        _panTintPolar = [[NSMutableArray alloc] init];
    }
    return _panTintPolar;
}


- (void)setChannelCount:(NSInteger)channelCount
{
    
    if (self.illRoleArray.count < channelCount) { 
        
        for (NSInteger row = self.illRoleArray.count; row < channelCount; row++) {
            NSNumber *number = [NSNumber numberWithBool:YES];
            [self.illRoleArray setObject:number atIndexedSubscript:row];
        }
        
    }else {
        
        for (NSInteger row = channelCount; row < self.illRoleArray.count; row++) {
            [self.illRoleArray removeObjectAtIndex:row];
        }
    }
    
    _channelCount = channelCount;
    
}


- (NSMutableArray *)illRoleArray {
    if (!_illRoleArray) {
        _illRoleArray = [[NSMutableArray alloc] init];
    }
    return _illRoleArray;
}

@end
