








#import "LinkSignOffMay.h"

#define TitleStrategy self.frame.size.width

@interface LinkSignOffMay()



@property (nonatomic, strong) NSMutableArray                            *highestArray;



@property (nonatomic, strong) NSMutableArray <FloatDueAllKinCell *>      *mathArray;



@property (strong, nonatomic) NSMutableArray <FloatDueAllKinCell *>      *busyIcyChain;



@property (assign, nonatomic) NSInteger                                 count;



@property (nonatomic, assign) ArtKitLoadingStaticMastering                          status;



@property (nonatomic, assign) NSInteger                                 channelCount;



@property (nonatomic, assign) CGFloat                                   creamy;

@end

@implementation LinkSignOffMay

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

- (void)occurAirBits
{
    
    if (self.mathArray.firstObject) {
        
        
        FloatDueAllKinCell *redIconView = self.mathArray.firstObject;
        
        redIconView.frame = CGRectMake(TitleStrategy, 0, redIconView.hintSpaSize.width, redIconView.hintSpaSize.height);
        
        self.creamy = redIconView.creamy;
        
        self.channelCount = redIconView.channelCount;
        
        
        NSInteger row = [self unifyPeopleHoverGurationOperatorExportingOut:redIconView];
        
        
        if (row >= 0) {
            
            
            [self.mathArray removeObjectAtIndex:0];
            
            
            if (![self.subviews containsObject:redIconView]) {
                [self addSubview:redIconView];
            }
            redIconView.frame = CGRectMake(TitleStrategy,  row * (redIconView.hintSpaSize.height + _creamy), redIconView.hintSpaSize.width, redIconView.hintSpaSize.height);
            
            
            [_highestArray setObject:redIconView atIndexedSubscript:row];
            
            
            if ([self.delegate respondsToSelector:@selector(reorderJouleView:willDisplayCell:)]) {
                [self.delegate reorderJouleView:self willDisplayCell:redIconView];
            }
            
            
            [self.busyIcyChain addObject:redIconView];
            
            [redIconView canSamplerTrialFoldChannel:^{
                
                
                [redIconView setTransform:CGAffineTransformMakeTranslation(- redIconView.frame.size.width-TitleStrategy, 0)];
                
            } completion:^(BOOL finished) {
                
                [redIconView removeFromSuperview];
                
                
                [self.busyIcyChain removeObject:redIconView];
                
                
                if ([self.delegate respondsToSelector:@selector(reorderJouleView:didEndDisplayingCell:)]) {
                    [self.delegate reorderJouleView:self didEndDisplayingCell:redIconView];
                }
                
                
                if (--self.count <= 0) {
                    if ([self.delegate respondsToSelector:@selector(obtainQualityDownDeprecateVeryYouEvaluateEuler:)]) {
                        [self.delegate obtainQualityDownDeprecateVeryYouEvaluateEuler:self];
                    }
                    self.count = 0;
                }
                
                

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


- (void)loudClipSubTap:(NSArray <FloatDueAllKinCell *> *)barrages
{
    self.count += barrages.count;
    [self.mathArray addObjectsFromArray:barrages];
}

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

- (void)stop
{
    if (self.status == MagicMutationWrittenPositionMayContained) {
        return;
    }
    self.status = MagicMutationWrittenPositionMayContained;
    
    if (self.busyIcyChain.count) {
        [self.busyIcyChain makeObjectsPerformSelector:@selector(pause)];
    }
    
    if (self.mathArray.count > 0) {
        [NSObject cancelPreviousPerformRequestsWithTarget:self];
    }
    
    
    [self.busyIcyChain  makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.channelCount       = 0;
    self.count              = 0;
    [self.busyIcyChain  removeAllObjects];
    [self.mathArray     removeAllObjects];
    [self.highestArray  removeAllObjects];
    
    self.busyIcyChain       = nil;
    self.mathArray          = nil;
    self.highestArray       = nil;
}


- (NSInteger)unifyPeopleHoverGurationOperatorExportingOut:(FloatDueAllKinCell *)newBarrage
{
    for (int row = 0; row<_highestArray.count; row++) {
        NSObject *object = _highestArray[row];
        if ([object isKindOfClass:[NSNumber class]]) { 
            
            return row;
            
        }else if ([object isKindOfClass:[FloatDueAllKinCell class]]) { 
            
            FloatDueAllKinCell *phrasePlus = (FloatDueAllKinCell*)object;
            
            if ([self unifyPeopleHoverGurationOperatorExportingOut:phrasePlus nodePrior:newBarrage]) {
                
                return row;
            }
        }
    }
    
    return -1;
}


- (BOOL)unifyPeopleHoverGurationOperatorExportingOut:(FloatDueAllKinCell *)phrasePlus nodePrior:(FloatDueAllKinCell *)newBarrage
{
    
    if (phrasePlus.status == LocalKilogramBasqueReversesOldEldest) {
        return NO;
    }
    
    
    CGRect rect = [phrasePlus.layer.presentationLayer frame];
    if (rect.origin.x>TitleStrategy - phrasePlus.frame.size.width) {
        
        return NO;
    }else if (rect.size.width == 0)
    {
        
        return NO;
    }
    else if (phrasePlus.frame.size.width > newBarrage.frame.size.width) {
        
        return YES;
    }else
    {
        
        CGFloat time = TitleStrategy/(TitleStrategy+newBarrage.frame.size.width)*newBarrage.seekContents;
        
        CGFloat fade = rect.origin.x - time/(phrasePlus.seekContents)*(TitleStrategy + phrasePlus.frame.size.width);
        if (fade < -phrasePlus.frame.size.width) {
            
            return YES;
        }
    }
    return NO;
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    UITouch *civil = [touches anyObject];
    CGPoint easyAndGet  = [civil locationInView:self];
    for (UIView *trusted in [self subviews])
    {
        if (![trusted isKindOfClass:[FloatDueAllKinCell class]]) continue;
        FloatDueAllKinCell *redIconView = (FloatDueAllKinCell *)trusted;
        if ([redIconView.layer.presentationLayer hitTest:easyAndGet])
        {
            
            if ([self.delegate respondsToSelector:@selector(reorderJouleView:postHormoneCell:)]) {
                [self.delegate reorderJouleView:self postHormoneCell:redIconView];
            }
            break;
        }
    }
}




- (NSMutableArray<FloatDueAllKinCell *> *)mathArray {
    if (!_mathArray) {
        _mathArray = [[NSMutableArray alloc] init];
    }
    return _mathArray;
}


- (NSMutableArray<FloatDueAllKinCell *> *)busyIcyChain {
    if (!_busyIcyChain) {
        _busyIcyChain = [[NSMutableArray alloc] init];
    }
    return _busyIcyChain;
}


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


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

@end
