








#import "DrumWayTrapSay.h"

#define EarCutBeatAsk self.frame.size.width

@interface DrumWayTrapSay()



@property (nonatomic, strong) NSMutableArray                            *poolAgeArray;



@property (nonatomic, strong) NSMutableArray <HeadBookEarNotCell *>      *denyArray;



@property (strong, nonatomic) NSMutableArray <HeadBookEarNotCell *>      *middlePinSon;



@property (assign, nonatomic) NSInteger                                 count;



@property (nonatomic, assign) ThreeRematchClampingCookiesTwo                          status;



@property (nonatomic, assign) NSInteger                                 channelCount;



@property (nonatomic, assign) CGFloat                                   mayMin;

@end

@implementation DrumWayTrapSay

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

- (void)unlockAnyRun
{
    
    if (self.denyArray.firstObject) {
        
        
        HeadBookEarNotCell *putFoodView = self.denyArray.firstObject;
        
        putFoodView.frame = CGRectMake(EarCutBeatAsk, 0, putFoodView.penCubeSize.width, putFoodView.penCubeSize.height);
        
        self.mayMin = putFoodView.mayMin;
        
        self.channelCount = putFoodView.channelCount;
        
        
        NSInteger row = [self chapterPrimeLappishFitPolarConcludeSafety:putFoodView];
        
        
        if (row >= 0) {
            
            
            [self.denyArray removeObjectAtIndex:0];
            
            
            if (![self.subviews containsObject:putFoodView]) {
                [self addSubview:putFoodView];
            }
            putFoodView.frame = CGRectMake(EarCutBeatAsk,  row * (putFoodView.penCubeSize.height + _mayMin), putFoodView.penCubeSize.width, putFoodView.penCubeSize.height);
            
            
            [_poolAgeArray setObject:putFoodView atIndexedSubscript:row];
            
            
            if ([self.delegate respondsToSelector:@selector(launchedTradView:willDisplayCell:)]) {
                [self.delegate launchedTradView:self willDisplayCell:putFoodView];
            }
            
            
            [self.middlePinSon addObject:putFoodView];
            
            [putFoodView redNotHueBridgedItalics:^{
                
                
                [putFoodView setTransform:CGAffineTransformMakeTranslation(- putFoodView.frame.size.width-EarCutBeatAsk, 0)];
                
            } completion:^(BOOL finished) {
                
                [putFoodView removeFromSuperview];
                
                
                [self.middlePinSon removeObject:putFoodView];
                
                
                if ([self.delegate respondsToSelector:@selector(launchedTradView:didEndDisplayingCell:)]) {
                    [self.delegate launchedTradView:self didEndDisplayingCell:putFoodView];
                }
                
                
                if (--self.count <= 0) {
                    if ([self.delegate respondsToSelector:@selector(masterTreeLockSelectorsDogBreakEmailAcute:)]) {
                        [self.delegate masterTreeLockSelectorsDogBreakEmailAcute:self];
                    }
                    self.count = 0;
                }
                
                

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


- (void)looseEarEraHex:(NSArray <HeadBookEarNotCell *> *)barrages
{
    self.count += barrages.count;
    [self.denyArray addObjectsFromArray:barrages];
}

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

- (void)stop
{
    if (self.status == GermanTabKilohertzLandmarkResonantIcon) {
        return;
    }
    self.status = GermanTabKilohertzLandmarkResonantIcon;
    
    if (self.middlePinSon.count) {
        [self.middlePinSon makeObjectsPerformSelector:@selector(pause)];
    }
    
    if (self.denyArray.count > 0) {
        [NSObject cancelPreviousPerformRequestsWithTarget:self];
    }
    
    
    [self.middlePinSon  makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.channelCount       = 0;
    self.count              = 0;
    [self.middlePinSon  removeAllObjects];
    [self.denyArray     removeAllObjects];
    [self.poolAgeArray  removeAllObjects];
    
    self.middlePinSon       = nil;
    self.denyArray          = nil;
    self.poolAgeArray       = nil;
}


- (NSInteger)chapterPrimeLappishFitPolarConcludeSafety:(HeadBookEarNotCell *)newBarrage
{
    for (int row = 0; row<_poolAgeArray.count; row++) {
        NSObject *object = _poolAgeArray[row];
        if ([object isKindOfClass:[NSNumber class]]) { 
            
            return row;
            
        }else if ([object isKindOfClass:[HeadBookEarNotCell class]]) { 
            
            HeadBookEarNotCell *barSuchShe = (HeadBookEarNotCell*)object;
            
            if ([self chapterPrimeLappishFitPolarConcludeSafety:barSuchShe scoreFilm:newBarrage]) {
                
                return row;
            }
        }
    }
    
    return -1;
}


- (BOOL)chapterPrimeLappishFitPolarConcludeSafety:(HeadBookEarNotCell *)barSuchShe scoreFilm:(HeadBookEarNotCell *)newBarrage
{
    
    if (barSuchShe.status == EmergencyProducesUnableHigherReasonFor) {
        return NO;
    }
    
    
    CGRect rect = [barSuchShe.layer.presentationLayer frame];
    if (rect.origin.x>EarCutBeatAsk - barSuchShe.frame.size.width) {
        
        return NO;
    }else if (rect.size.width == 0)
    {
        
        return NO;
    }
    else if (barSuchShe.frame.size.width > newBarrage.frame.size.width) {
        
        return YES;
    }else
    {
        
        CGFloat time = EarCutBeatAsk/(EarCutBeatAsk+newBarrage.frame.size.width)*newBarrage.quietBitHang;
        
        CGFloat trad = rect.origin.x - time/(barSuchShe.quietBitHang)*(EarCutBeatAsk + barSuchShe.frame.size.width);
        if (trad < -barSuchShe.frame.size.width) {
            
            return YES;
        }
    }
    return NO;
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    UITouch *panel = [touches anyObject];
    CGPoint workDerive  = [panel locationInView:self];
    for (UIView *friends in [self subviews])
    {
        if (![friends isKindOfClass:[HeadBookEarNotCell class]]) continue;
        HeadBookEarNotCell *putFoodView = (HeadBookEarNotCell *)friends;
        if ([putFoodView.layer.presentationLayer hitTest:workDerive])
        {
            
            if ([self.delegate respondsToSelector:@selector(launchedTradView:keyLoveLongCell:)]) {
                [self.delegate launchedTradView:self keyLoveLongCell:putFoodView];
            }
            break;
        }
    }
}




- (NSMutableArray<HeadBookEarNotCell *> *)denyArray {
    if (!_denyArray) {
        _denyArray = [[NSMutableArray alloc] init];
    }
    return _denyArray;
}


- (NSMutableArray<HeadBookEarNotCell *> *)middlePinSon {
    if (!_middlePinSon) {
        _middlePinSon = [[NSMutableArray alloc] init];
    }
    return _middlePinSon;
}


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


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

@end
