








#import "MakeChestGreat.h"

#define FitFaxCalorie self.frame.size.width

@interface MakeChestGreat()



@property (nonatomic, strong) NSMutableArray                            *moveForArray;



@property (nonatomic, strong) NSMutableArray <MostCustomIronCell *>      *axesArray;



@property (strong, nonatomic) NSMutableArray <MostCustomIronCell *>      *fiveAlertSub;



@property (assign, nonatomic) NSInteger                                 count;



@property (nonatomic, assign) RaceClearKitSpecifierMail                          status;



@property (nonatomic, assign) NSInteger                                 channelCount;



@property (nonatomic, assign) CGFloat                                   reader;

@end

@implementation MakeChestGreat

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

- (void)allDecayMole
{
    
    if (self.axesArray.firstObject) {
        
        
        MostCustomIronCell *recycleView = self.axesArray.firstObject;
        
        recycleView.frame = CGRectMake(FitFaxCalorie, 0, recycleView.pastOwnSize.width, recycleView.pastOwnSize.height);
        
        self.reader = recycleView.reader;
        
        self.channelCount = recycleView.channelCount;
        
        
        NSInteger row = [self badmintonAutoMapDistinctInsertionAbsentFinalize:recycleView];
        
        
        if (row >= 0) {
            
            
            [self.axesArray removeObjectAtIndex:0];
            
            
            if (![self.subviews containsObject:recycleView]) {
                [self addSubview:recycleView];
            }
            recycleView.frame = CGRectMake(FitFaxCalorie,  row * (recycleView.pastOwnSize.height + _reader), recycleView.pastOwnSize.width, recycleView.pastOwnSize.height);
            
            
            [_moveForArray setObject:recycleView atIndexedSubscript:row];
            
            
            if ([self.delegate respondsToSelector:@selector(cutButDetailView:willDisplayCell:)]) {
                [self.delegate cutButDetailView:self willDisplayCell:recycleView];
            }
            
            
            [self.fiveAlertSub addObject:recycleView];
            
            [recycleView fitnessCurveDecipherBinLinear:^{
                
                
                [recycleView setTransform:CGAffineTransformMakeTranslation(- recycleView.frame.size.width-FitFaxCalorie, 0)];
                
            } completion:^(BOOL finished) {
                
                [recycleView removeFromSuperview];
                
                
                [self.fiveAlertSub removeObject:recycleView];
                
                
                if ([self.delegate respondsToSelector:@selector(cutButDetailView:didEndDisplayingCell:)]) {
                    [self.delegate cutButDetailView:self didEndDisplayingCell:recycleView];
                }
                
                
                if (--self.count <= 0) {
                    if ([self.delegate respondsToSelector:@selector(notActionBeatFinderVerticalSelectionSemanticCenters:)]) {
                        [self.delegate notActionBeatFinderVerticalSelectionSemanticCenters:self];
                    }
                    self.count = 0;
                }
                
                

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


- (void)priceCharBlood:(NSArray <MostCustomIronCell *> *)barrages
{
    self.count += barrages.count;
    [self.axesArray addObjectsFromArray:barrages];
}

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

- (void)stop
{
    if (self.status == OverlayLinkageBannerLightThumbFrame) {
        return;
    }
    self.status = OverlayLinkageBannerLightThumbFrame;
    
    if (self.fiveAlertSub.count) {
        [self.fiveAlertSub makeObjectsPerformSelector:@selector(pause)];
    }
    
    if (self.axesArray.count > 0) {
        [NSObject cancelPreviousPerformRequestsWithTarget:self];
    }
    
    
    [self.fiveAlertSub  makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.channelCount       = 0;
    self.count              = 0;
    [self.fiveAlertSub  removeAllObjects];
    [self.axesArray     removeAllObjects];
    [self.moveForArray  removeAllObjects];
    
    self.fiveAlertSub       = nil;
    self.axesArray          = nil;
    self.moveForArray       = nil;
}


- (NSInteger)badmintonAutoMapDistinctInsertionAbsentFinalize:(MostCustomIronCell *)newBarrage
{
    for (int row = 0; row<_moveForArray.count; row++) {
        NSObject *object = _moveForArray[row];
        if ([object isKindOfClass:[NSNumber class]]) { 
            
            return row;
            
        }else if ([object isKindOfClass:[MostCustomIronCell class]]) { 
            
            MostCustomIronCell *nowOutputs = (MostCustomIronCell*)object;
            
            if ([self badmintonAutoMapDistinctInsertionAbsentFinalize:nowOutputs overClaim:newBarrage]) {
                
                return row;
            }
        }
    }
    
    return -1;
}


- (BOOL)badmintonAutoMapDistinctInsertionAbsentFinalize:(MostCustomIronCell *)nowOutputs overClaim:(MostCustomIronCell *)newBarrage
{
    
    if (nowOutputs.status == FarTalkBigOrnamentsTagUnderline) {
        return NO;
    }
    
    
    CGRect rect = [nowOutputs.layer.presentationLayer frame];
    if (rect.origin.x>FitFaxCalorie - nowOutputs.frame.size.width) {
        
        return NO;
    }else if (rect.size.width == 0)
    {
        
        return NO;
    }
    else if (nowOutputs.frame.size.width > newBarrage.frame.size.width) {
        
        return YES;
    }else
    {
        
        CGFloat time = FitFaxCalorie/(FitFaxCalorie+newBarrage.frame.size.width)*newBarrage.twentyNetOdd;
        
        CGFloat snap = rect.origin.x - time/(nowOutputs.twentyNetOdd)*(FitFaxCalorie + nowOutputs.frame.size.width);
        if (snap < -nowOutputs.frame.size.width) {
            
            return YES;
        }
    }
    return NO;
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    UITouch *phone = [touches anyObject];
    CGPoint flushPulse  = [phone locationInView:self];
    for (MostCustomIronCell *recycleView in [self subviews])
    {
        if ([recycleView.layer.presentationLayer hitTest:flushPulse])
        {
            
            if ([self.delegate respondsToSelector:@selector(cutButDetailView:catCloudYouCell:)]) {
                [self.delegate cutButDetailView:self catCloudYouCell:recycleView];
            }
            break;
        }
    }
}




- (NSMutableArray<MostCustomIronCell *> *)axesArray {
    if (!_axesArray) {
        _axesArray = [[NSMutableArray alloc] init];
    }
    return _axesArray;
}


- (NSMutableArray<MostCustomIronCell *> *)fiveAlertSub {
    if (!_fiveAlertSub) {
        _fiveAlertSub = [[NSMutableArray alloc] init];
    }
    return _fiveAlertSub;
}


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


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

@end
