








#import "QuoteCarRawCut.h"

#define KitDidNapSpan self.frame.size.width

@interface QuoteCarRawCut()



@property (nonatomic, strong) NSMutableArray                            *hairSobArray;



@property (nonatomic, strong) NSMutableArray <VideoCaretFeedCell *>      *tallArray;



@property (strong, nonatomic) NSMutableArray <VideoCaretFeedCell *>      *askFarNative;



@property (assign, nonatomic) NSInteger                                 count;



@property (nonatomic, assign) CauseOwnershipEligibleLooperTrad                          status;



@property (nonatomic, assign) NSInteger                                 channelCount;



@property (nonatomic, assign) CGFloat                                   purple;

@end

@implementation QuoteCarRawCut

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

- (void)syntheticDry
{
    
    if (self.tallArray.firstObject) {
        
        
        VideoCaretFeedCell *boldMixView = self.tallArray.firstObject;
        
        boldMixView.frame = CGRectMake(KitDidNapSpan, 0, boldMixView.farEachSize.width, boldMixView.farEachSize.height);
        
        self.purple = boldMixView.purple;
        
        self.channelCount = boldMixView.channelCount;
        
        
        NSInteger row = [self gatheringEntitledSpineCharClustersEndSolo:boldMixView];
        
        
        if (row >= 0) {
            
            
            [self.tallArray removeObjectAtIndex:0];
            
            
            if (![self.subviews containsObject:boldMixView]) {
                [self addSubview:boldMixView];
            }
            boldMixView.frame = CGRectMake(KitDidNapSpan,  row * (boldMixView.farEachSize.height + _purple), boldMixView.farEachSize.width, boldMixView.farEachSize.height);
            
            
            [_hairSobArray setObject:boldMixView atIndexedSubscript:row];
            
            
            if ([self.delegate respondsToSelector:@selector(incomingPastView:willDisplayCell:)]) {
                [self.delegate incomingPastView:self willDisplayCell:boldMixView];
            }
            
            
            [self.askFarNative addObject:boldMixView];
            
            [boldMixView withinCompactWhoInvitePong:^{
                
                
                [boldMixView setTransform:CGAffineTransformMakeTranslation(- boldMixView.frame.size.width-KitDidNapSpan, 0)];
                
            } completion:^(BOOL finished) {
                
                [boldMixView removeFromSuperview];
                
                
                [self.askFarNative removeObject:boldMixView];
                
                
                if ([self.delegate respondsToSelector:@selector(incomingPastView:didEndDisplayingCell:)]) {
                    [self.delegate incomingPastView:self didEndDisplayingCell:boldMixView];
                }
                
                
                if (--self.count <= 0) {
                    if ([self.delegate respondsToSelector:@selector(artStrideVitalDesignEuropeanMinimizeSenseExpired:)]) {
                        [self.delegate artStrideVitalDesignEuropeanMinimizeSenseExpired:self];
                    }
                    self.count = 0;
                }
                
                

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


- (void)wetShiftAndPin:(NSArray <VideoCaretFeedCell *> *)barrages
{
    self.count += barrages.count;
    [self.tallArray addObjectsFromArray:barrages];
}

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

- (void)stop
{
    if (self.status == HowCoulombsSonSolveButPeriod) {
        return;
    }
    self.status = HowCoulombsSonSolveButPeriod;
    
    if (self.askFarNative.count) {
        [self.askFarNative makeObjectsPerformSelector:@selector(pause)];
    }
    
    if (self.tallArray.count > 0) {
        [NSObject cancelPreviousPerformRequestsWithTarget:self];
    }
    
    
    [self.askFarNative  makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.channelCount       = 0;
    self.count              = 0;
    [self.askFarNative  removeAllObjects];
    [self.tallArray     removeAllObjects];
    [self.hairSobArray  removeAllObjects];
    
    self.askFarNative       = nil;
    self.tallArray          = nil;
    self.hairSobArray       = nil;
}


- (NSInteger)gatheringEntitledSpineCharClustersEndSolo:(VideoCaretFeedCell *)newBarrage
{
    for (int row = 0; row<_hairSobArray.count; row++) {
        NSObject *object = _hairSobArray[row];
        if ([object isKindOfClass:[NSNumber class]]) { 
            
            return row;
            
        }else if ([object isKindOfClass:[VideoCaretFeedCell class]]) { 
            
            VideoCaretFeedCell *outputPlay = (VideoCaretFeedCell*)object;
            
            if ([self gatheringEntitledSpineCharClustersEndSolo:outputPlay truncates:newBarrage]) {
                
                return row;
            }
        }
    }
    
    return -1;
}


- (BOOL)gatheringEntitledSpineCharClustersEndSolo:(VideoCaretFeedCell *)outputPlay truncates:(VideoCaretFeedCell *)newBarrage
{
    
    if (outputPlay.status == BusStoodAndEditorConverterArmenian) {
        return NO;
    }
    
    
    CGRect rect = [outputPlay.layer.presentationLayer frame];
    if (rect.origin.x>KitDidNapSpan - outputPlay.frame.size.width) {
        
        return NO;
    }else if (rect.size.width == 0)
    {
        
        return NO;
    }
    else if (outputPlay.frame.size.width > newBarrage.frame.size.width) {
        
        return YES;
    }else
    {
        
        CGFloat time = KitDidNapSpan/(KitDidNapSpan+newBarrage.frame.size.width)*newBarrage.briefSeeHard;
        
        CGFloat gasp = rect.origin.x - time/(outputPlay.briefSeeHard)*(KitDidNapSpan + outputPlay.frame.size.width);
        if (gasp < -outputPlay.frame.size.width) {
            
            return YES;
        }
    }
    return NO;
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    UITouch *found = [touches anyObject];
    CGPoint smilePhone  = [found locationInView:self];
    for (VideoCaretFeedCell *boldMixView in [self subviews])
    {
        if ([boldMixView.layer.presentationLayer hitTest:smilePhone])
        {
            
            if ([self.delegate respondsToSelector:@selector(incomingPastView:pageOffPeerCell:)]) {
                [self.delegate incomingPastView:self pageOffPeerCell:boldMixView];
            }
            break;
        }
    }
}




- (NSMutableArray<VideoCaretFeedCell *> *)tallArray {
    if (!_tallArray) {
        _tallArray = [[NSMutableArray alloc] init];
    }
    return _tallArray;
}


- (NSMutableArray<VideoCaretFeedCell *> *)askFarNative {
    if (!_askFarNative) {
        _askFarNative = [[NSMutableArray alloc] init];
    }
    return _askFarNative;
}


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


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

@end
