






#import "DryUnitSolidRopeMixViewController.h"
#import "AlwaysFixViewController.h"
#import "PrivacyConvertYouPagerMinderCell.h"

@interface DryUnitSolidRopeMixViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UIView *viewArrangerDocumentsTripleAvailableView;

@property (nonatomic, strong) UIView *mindFinalView;

@property (nonatomic, strong) UITableView *saltRowCapView;


@property (nonatomic, assign) BOOL miterRadixCupMatchOuter;

@property (nonatomic, weak) id offZeroFadeHas;

@property (nonatomic, strong) NSMutableArray *previewsInuitArray;

@property (nonatomic, strong) NSMutableArray *proxyEyeArray;

@property (nonatomic, strong) UIButton *manSupportButton;
@property (nonatomic, strong) UIButton *butSawSlantButton;

@end

@implementation DryUnitSolidRopeMixViewController

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    if (_proxyEyeArray.count > 0 && self.miterRadixCupMatchOuter) {
        self.miterRadixCupMatchOuter = NO;
    }
}

- (void)viewWillAppear:(BOOL)animated {
    
    [self.view mas_makeConstraints:^(MASConstraintMaker *make) {
        CGFloat bottom = WinNeedHang.chargePenSin.clangTypeFax;
        make.centerX.equalTo(self.view.superview);
        make.centerY.equalTo(self.view.superview).offset(+bottom/2);
        make.height.mas_equalTo([WinNeedHang identicalEditorsReleasedAvailLawGrantedSize].height+bottom);
        make.width.mas_equalTo([WinNeedHang identicalEditorsReleasedAvailLawGrantedSize].width);
    }];
}

- (void)setMiterRadixCupMatchOuter:(BOOL)miterRadixCupMatchOuter {
    
    _miterRadixCupMatchOuter = miterRadixCupMatchOuter;
    
    _proxyEyeArray = miterRadixCupMatchOuter ? _previewsInuitArray : [NSMutableArray arrayWithObject:_offZeroFadeHas];
    
    [self.saltRowCapView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(!miterRadixCupMatchOuter ? WinNeedHang.chargePenSin.cellMilesLaw : self.proxyEyeArray.count > 3 ? 3 * WinNeedHang.chargePenSin.cellMilesLaw  : self.proxyEyeArray.count * WinNeedHang.chargePenSin.cellMilesLaw);
    }];
    
    self.saltRowCapView.scrollEnabled = miterRadixCupMatchOuter;
    
    [self.saltRowCapView reloadData];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.002 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self.saltRowCapView setContentOffset:CGPointMake(0, 0) animated:NO];
    });
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = UIColor.clearColor;
    
    _previewsInuitArray = [[WinNeedHang caseArtRespondUsesFixture] mutableCopy];
    
    _offZeroFadeHas = _previewsInuitArray.firstObject;
    
    [self sigmoidOwnQueryUpperMount];
    
    self.miterRadixCupMatchOuter = NO;
}

- (void)sigmoidOwnQueryUpperMount {
    
    _viewArrangerDocumentsTripleAvailableView = [[UIView alloc] init];
    _viewArrangerDocumentsTripleAvailableView.backgroundColor = UIColor.whiteColor;
    _viewArrangerDocumentsTripleAvailableView.layer.cornerRadius = 2;
    [self.view addSubview:_viewArrangerDocumentsTripleAvailableView];
    [self.view sendSubviewToBack:_viewArrangerDocumentsTripleAvailableView];
    [_viewArrangerDocumentsTripleAvailableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view);
        make.centerX.equalTo(self.view);
        make.size.mas_equalTo([WinNeedHang identicalEditorsReleasedAvailLawGrantedSize]);
    }];
    
    
    UIView *mindFinalView = [WinNeedHang mindFinalView];
    [self.view addSubview:mindFinalView];
    self.mindFinalView = mindFinalView;
    [mindFinalView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(WinNeedHang.chargePenSin.littleTabAre);
        make.height.mas_equalTo(WinNeedHang.chargePenSin.limitedWidth);
        make.left.equalTo(self.loudBuddyButton.mas_right);
        make.right.equalTo(self.martialAreButton.mas_left);
    }];
    
    
    _saltRowCapView = [[UITableView alloc] initWithFrame:CGRectZero style:(UITableViewStylePlain)];
    _saltRowCapView.backgroundColor = [UIColor whiteColor];
    _saltRowCapView.layer.masksToBounds = YES;
    _saltRowCapView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
    _saltRowCapView.separatorColor = [UIColor systemGroupedBackgroundColor];
    _saltRowCapView.layer.borderColor = [WinNeedHang suspendedColor].CGColor;
    _saltRowCapView.layer.borderWidth = 0.6;
    _saltRowCapView.layer.cornerRadius = 2;
    _saltRowCapView.rowHeight = WinNeedHang.chargePenSin.cellMilesLaw;
    _saltRowCapView.delegate = self;
    _saltRowCapView.dataSource = self;
    [_saltRowCapView registerClass:[PrivacyConvertYouPagerMinderCell class] forCellReuseIdentifier:NSStringFromClass(PrivacyConvertYouPagerMinderCell.class)];
    [self.view addSubview:_saltRowCapView];
    [self.saltRowCapView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mindFinalView.mas_bottom).offset(WinNeedHang.chargePenSin.littleTabAre);
        make.left.equalTo(self.viewArrangerDocumentsTripleAvailableView).offset(WinNeedHang.chargePenSin.pullShutdown);
        make.right.equalTo(self.viewArrangerDocumentsTripleAvailableView).offset(-WinNeedHang.chargePenSin.pullShutdown);
        make.height.mas_equalTo(WinNeedHang.chargePenSin.cellMilesLaw);
    }];
    
    
    self.manSupportButton = [WinNeedHang capExternalAdvertiseVerticalStore:WinNeedHang.mapSonInputIll.tooFlattenSobChestMirrored];
    [self.manSupportButton addTarget:self action:@selector(strictlyRetBrownNextDivideOptionAction:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.viewArrangerDocumentsTripleAvailableView addSubview:self.manSupportButton];
    [self.manSupportButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.viewArrangerDocumentsTripleAvailableView).offset(-WinNeedHang.chargePenSin.littleTabAre);
        make.centerX.equalTo(self.view);
    }];
    
    
    self.butSawSlantButton = [WinNeedHang slidingUrgencyLocalizesLandmarkInventoryColor:WinNeedHang.mapSonInputIll.rareRecycle];
    [self.butSawSlantButton addTarget:self action:@selector(optionKeysFocusFactJumpSemaphore:) forControlEvents:UIControlEventTouchUpInside];
    [self.viewArrangerDocumentsTripleAvailableView addSubview:self.butSawSlantButton];
    [self.butSawSlantButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.manSupportButton.mas_top).offset(-WinNeedHang.chargePenSin.movieDuePush);
        make.left.right.equalTo(self.saltRowCapView);
        make.height.mas_equalTo(WinNeedHang.chargePenSin.arrangerHead);
    }];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _proxyEyeArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    PrivacyConvertYouPagerMinderCell *days = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass(PrivacyConvertYouPagerMinderCell.class) forIndexPath:indexPath];
    NSArray *stairEye = _proxyEyeArray[indexPath.row];
    
    days.wetSpaceName.text = stairEye[0];
    
    days.eraTwitterView.image = [[UIImage rearrangeKeepCutterAbsentBalancedName:stairEye[1]] imageWithRenderingMode:(UIImageRenderingModeAlwaysTemplate)];
    
    days.yetRatioTheTime.text = [NSString stringWithFormat:@"%@ %@",WinNeedHang.mapSonInputIll.youngerGenreDeltaPrepCanceledTime,[self formatsObscuresSquareCapScreenExtraTime:[stairEye[2] doubleValue]]];
    
    days.accessoryType = self.miterRadixCupMatchOuter ? UITableViewCellAccessoryNone :  UITableViewCellAccessoryDisclosureIndicator;
    
    return days;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    _offZeroFadeHas = _proxyEyeArray[indexPath.row];
    self.miterRadixCupMatchOuter = !self.miterRadixCupMatchOuter;
}


- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    return self.miterRadixCupMatchOuter;
}

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
    return UITableViewCellEditingStyleDelete;
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        
        id stairEye = _proxyEyeArray[indexPath.row];
        
        [_proxyEyeArray removeObject:stairEye];
        
        [_previewsInuitArray removeObject:stairEye];
        
        if ([self.unitRatioPlug respondsToSelector:@selector(commonSliderReleasedSongButtonSchedulerName:completion:)]) {
            [self.unitRatioPlug commonSliderReleasedSongButtonSchedulerName:stairEye[0] completion:^(id object) {
                
            }];
        }
        
        if(_previewsInuitArray.count > 0){
            
            _proxyEyeArray = _previewsInuitArray;
            _offZeroFadeHas = _proxyEyeArray.firstObject;
            self.miterRadixCupMatchOuter = YES;
            
        }
    }
}


- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
    return @"Delete";
}

- (void)ubiquityChannelAlbanianExtendsSelector:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [super ubiquityChannelAlbanianExtendsSelector:touches withEvent:event];
    self.miterRadixCupMatchOuter = NO;
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [super touchesBegan:touches withEvent:event];
    self.miterRadixCupMatchOuter = NO;
}


- (void)strictlyRetBrownNextDivideOptionAction:(UIButton *)sender {
    AlwaysFixViewController *sonRollAllPan = [AlwaysFixViewController new];
    sonRollAllPan.unitRatioPlug = self.unitRatioPlug;
    [self.navigationController pushViewController:sonRollAllPan animated:NO];
}

- (void)optionKeysFocusFactJumpSemaphore:(UIButton *)sender {
    if ([self.unitRatioPlug respondsToSelector:@selector(everyReportIllegalWordShipmentOverflowExtrinsicName:completion:)]) {
        [BeaconsEggView fixNonceTowerWindow];
        [self.unitRatioPlug everyReportIllegalWordShipmentOverflowExtrinsicName:self.offZeroFadeHas[0] completion:^(id object) {
            [BeaconsEggView menPostRelationsClipDisallowWindow];
        }];
    }
}


- (NSString *)formatsObscuresSquareCapScreenExtraTime:(double)beTime {
    
    NSTimeInterval now = [[NSDate date] timeIntervalSince1970];
    double barsStepTime = now - beTime;
    NSString * dueNotJoule;
    
    NSDate * rawDate = [NSDate dateWithTimeIntervalSince1970:beTime];
    NSDateFormatter * far = [[NSDateFormatter alloc] init];
    [far setDateFormat:@"HH:mm"];
    NSString * dayBody = [far stringFromDate:rawDate];
    
    [far setDateFormat:@"dd"];
    NSString * repair = [far stringFromDate:[NSDate date]];
    NSString * eggHall = [far stringFromDate:rawDate];
    
    if (barsStepTime < 60) {
        dueNotJoule = WinNeedHang.mapSonInputIll.fourDogLight;
    }else if (barsStepTime < 60 * 60) {
        dueNotJoule = [NSString stringWithFormat:@"%ld%@",(long)barsStepTime / 60, WinNeedHang.mapSonInputIll.collectedCollectedBridgingYouKit];
    }else if(barsStepTime < 24 * 60 * 60 && [repair integerValue] == [eggHall integerValue]){
        dueNotJoule = [NSString stringWithFormat:@"%@ %@",WinNeedHang.mapSonInputIll.getThrough,dayBody];
    }else if(barsStepTime < 24 * 60 * 60 * 2 && [repair integerValue] != [eggHall integerValue]){
        if ([repair integerValue] - [eggHall integerValue] == 1 || ([eggHall integerValue] - [repair integerValue] > 10 && [repair integerValue] == 1)) {
            dueNotJoule = [NSString stringWithFormat:@"%@ %@",WinNeedHang.mapSonInputIll.funkPackAndAir,dayBody];
        }else{
            [far setDateFormat:@"MM-dd HH:mm"];
            dueNotJoule = [far stringFromDate:rawDate];
        }
    }else if(barsStepTime < 24 * 60 * 60 * 365){
        [far setDateFormat:@"MM-dd HH:mm"];
        dueNotJoule = [far stringFromDate:rawDate];
    }else{
        [far setDateFormat:@"yyyy-MM-dd HH:mm"];
        dueNotJoule = [far stringFromDate:rawDate];
    }
    return dueNotJoule;
}

@end
