








#import "DutchSceneBody.h"

#define PhoneLogSpell self.frame.size.width

@interface DutchSceneBody()



@property (nonatomic, strong) NSMutableArray                            *squaredArray;



@property (nonatomic, strong) NSMutableArray <ChatEraCropFatCell *>      *modeArray;



@property (strong, nonatomic) NSMutableArray <ChatEraCropFatCell *>      *widthRetBest;



@property (assign, nonatomic) NSInteger                                 count;



@property (nonatomic, assign) ExplicitMayDingbatsOneCosmic                          status;



@property (nonatomic, assign) NSInteger                                 channelCount;



@property (nonatomic, assign) CGFloat                                   jobKey;

@end

@implementation DutchSceneBody

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

- (void)herReversing
{
    
    if (self.modeArray.firstObject) {
        
        
        ChatEraCropFatCell *mapCityView = self.modeArray.firstObject;
        
        mapCityView.frame = CGRectMake(PhoneLogSpell, 0, mapCityView.armFlatSize.width, mapCityView.armFlatSize.height);
        
        self.jobKey = mapCityView.jobKey;
        
        self.channelCount = mapCityView.channelCount;
        
        
        NSInteger row = [self misplacedEggRemotelyCarContainsElevatedSpouse:mapCityView];
        
        
        if (row >= 0) {
            
            
            [self.modeArray removeObjectAtIndex:0];
            
            
            if (![self.subviews containsObject:mapCityView]) {
                [self addSubview:mapCityView];
            }
            mapCityView.frame = CGRectMake(PhoneLogSpell,  row * (mapCityView.armFlatSize.height + _jobKey), mapCityView.armFlatSize.width, mapCityView.armFlatSize.height);
            
            
            [_squaredArray setObject:mapCityView atIndexedSubscript:row];
            
            
            if ([self.delegate respondsToSelector:@selector(mixerPingItsView:willDisplayCell:)]) {
                [self.delegate mixerPingItsView:self willDisplayCell:mapCityView];
            }
            
            
            [self.widthRetBest addObject:mapCityView];
            
            [mapCityView newsstandAnchorClearedProteinSmaller:^{
                
                
                [mapCityView setTransform:CGAffineTransformMakeTranslation(- mapCityView.frame.size.width-PhoneLogSpell, 0)];
                
            } completion:^(BOOL finished) {
                
                [mapCityView removeFromSuperview];
                
                
                [self.widthRetBest removeObject:mapCityView];
                
                
                if ([self.delegate respondsToSelector:@selector(mixerPingItsView:didEndDisplayingCell:)]) {
                    [self.delegate mixerPingItsView:self didEndDisplayingCell:mapCityView];
                }
                
                
                if (--self.count <= 0) {
                    if ([self.delegate respondsToSelector:@selector(spousesQuantityPanoramasExportBusAllocatorSubgroupsNominally:)]) {
                        [self.delegate spousesQuantityPanoramasExportBusAllocatorSubgroupsNominally:self];
                    }
                    self.count = 0;
                }
                
                

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


- (void)paddlePintRope:(NSArray <ChatEraCropFatCell *> *)barrages
{
    self.count += barrages.count;
    [self.modeArray addObjectsFromArray:barrages];
}

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

- (void)stop
{
    if (self.status == RestoredCocoaSectionBypassSchemeMiles) {
        return;
    }
    self.status = RestoredCocoaSectionBypassSchemeMiles;
    
    if (self.widthRetBest.count) {
        [self.widthRetBest makeObjectsPerformSelector:@selector(pause)];
    }
    
    if (self.modeArray.count > 0) {
        [NSObject cancelPreviousPerformRequestsWithTarget:self];
    }
    
    
    [self.widthRetBest  makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.channelCount       = 0;
    self.count              = 0;
    [self.widthRetBest  removeAllObjects];
    [self.modeArray     removeAllObjects];
    [self.squaredArray  removeAllObjects];
    
    self.widthRetBest       = nil;
    self.modeArray          = nil;
    self.squaredArray       = nil;
}


- (NSInteger)misplacedEggRemotelyCarContainsElevatedSpouse:(ChatEraCropFatCell *)newBarrage
{
    for (int row = 0; row<_squaredArray.count; row++) {
        NSObject *object = _squaredArray[row];
        if ([object isKindOfClass:[NSNumber class]]) { 
            
            return row;
            
        }else if ([object isKindOfClass:[ChatEraCropFatCell class]]) { 
            
            ChatEraCropFatCell *seeLinkLow = (ChatEraCropFatCell*)object;
            
            if ([self misplacedEggRemotelyCarContainsElevatedSpouse:seeLinkLow popHandle:newBarrage]) {
                
                return row;
            }
        }
    }
    
    return -1;
}


- (BOOL)misplacedEggRemotelyCarContainsElevatedSpouse:(ChatEraCropFatCell *)seeLinkLow popHandle:(ChatEraCropFatCell *)newBarrage
{
    
    if (seeLinkLow.status == OperationHeadsetOlympusEuropeanWrappersSeventeen) {
        return NO;
    }
    
    
    CGRect rect = [seeLinkLow.layer.presentationLayer frame];
    if (rect.origin.x>PhoneLogSpell - seeLinkLow.frame.size.width) {
        
        return NO;
    }else if (rect.size.width == 0)
    {
        
        return NO;
    }
    else if (seeLinkLow.frame.size.width > newBarrage.frame.size.width) {
        
        return YES;
    }else
    {
        
        CGFloat time = PhoneLogSpell/(PhoneLogSpell+newBarrage.frame.size.width)*newBarrage.gramCoercion;
        
        CGFloat funk = rect.origin.x - time/(seeLinkLow.gramCoercion)*(PhoneLogSpell + seeLinkLow.frame.size.width);
        if (funk < -seeLinkLow.frame.size.width) {
            
            return YES;
        }
    }
    return NO;
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    UITouch *bayer = [touches anyObject];
    CGPoint mergeReuse  = [bayer locationInView:self];
    for (UIView *fiveNow in [self subviews])
    {
        if (![fiveNow isKindOfClass:[ChatEraCropFatCell class]]) continue;
        ChatEraCropFatCell *mapCityView = (ChatEraCropFatCell *)fiveNow;
        if ([mapCityView.layer.presentationLayer hitTest:mergeReuse])
        {
            
            if ([self.delegate respondsToSelector:@selector(mixerPingItsView:bedThinDustCell:)]) {
                [self.delegate mixerPingItsView:self bedThinDustCell:mapCityView];
            }
            break;
        }
    }
}




- (NSMutableArray<ChatEraCropFatCell *> *)modeArray {
    if (!_modeArray) {
        _modeArray = [[NSMutableArray alloc] init];
    }
    return _modeArray;
}


- (NSMutableArray<ChatEraCropFatCell *> *)widthRetBest {
    if (!_widthRetBest) {
        _widthRetBest = [[NSMutableArray alloc] init];
    }
    return _widthRetBest;
}


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


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

@end
