






#import "NowMapPoolViewController.h"
#import "TaggingTwoConfig.h"
#import "NSObject+DidModel.h"
#import "UIColor+AirColor.h"
#import "AnyToast.h"

@interface NowMapPoolViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray<NSDictionary *> *forbiddenNineRatingsFlipSymptom; 
@property (nonatomic, strong) NSArray<NSArray<NSString *> *> *deltaChatOuter; 
@property (nonatomic, strong) NSMutableArray<NSString *> *sectionTitles; 

@end

@implementation NowMapPoolViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    _forbiddenNineRatingsFlipSymptom = [NSMutableArray array];
    _deltaChatOuter = @[];
    _sectionTitles = [NSMutableArray array];
    
    [self remoteYearView];
}

- (void)viewWillAppear:(BOOL)animated {
    
    UIEdgeInsets scaleCause = [[InterlaceManager shared] waxStreamOldWindow].safeAreaInsets;
    
    scaleCause.top    += 10;
    scaleCause.left   += 10;
    scaleCause.bottom += 10;
    scaleCause.right  += 10;

    [self.view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(scaleCause);
    }];
}


- (void)remoteYearView {
    _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
    _tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    _tableView.dataSource = self;
    _tableView.delegate = self;
    _tableView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:_tableView];
    [_tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.pinchHaveButton.mas_bottom);
        make.left.right.bottom.equalTo(self.view);
    }];
    
    
    [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:NSStringFromClass(self.class)];
}


- (NSArray<NSString *> *)mainPopFastSexDictionary:(NSDictionary *)lazy {
    return [[lazy allKeys] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
}

- (void)eyeFunHisMoreInfo:(NSDictionary *)info withTitle:(NSString *)title {
    if (!info || ![info isKindOfClass:[NSDictionary class]]) {
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        @synchronized (self) {
            
            [self->_forbiddenNineRatingsFlipSymptom addObject:[info copy]];
            NSArray *seeOffTall = [self mainPopFastSexDictionary:info];
            self->_deltaChatOuter = [self->_deltaChatOuter arrayByAddingObject:seeOffTall];
            [self->_sectionTitles addObject:title];
            
            
            [self.tableView reloadData];
        }
    });
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return _forbiddenNineRatingsFlipSymptom.count;
}

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

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    return _sectionTitles[section];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *thin = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass(self.class) forIndexPath:indexPath];
    
    NSString *key;
    id value;
    NSInteger privacyIndex = indexPath.section;
    key = _deltaChatOuter[privacyIndex][indexPath.row];
    value = _forbiddenNineRatingsFlipSymptom[privacyIndex][key];
    BOOL binBrief = [value isKindOfClass:[NSDictionary class]] || [value isKindOfClass:[NSArray class]];
    thin.backgroundColor = [UIColor clearColor];
    
    
    for (UIView *observe in thin.contentView.subviews) {
        [observe removeFromSuperview];
    }
    
    
    UILabel *tapLabel = [[UILabel alloc] init];
    tapLabel.font = [UIFont monospacedSystemFontOfSize:14 weight:UIFontWeightMedium];
    tapLabel.textColor = [UIColor darkGrayColor];
    tapLabel.text = key;
    tapLabel.numberOfLines = 0;
    [thin.contentView addSubview:tapLabel];
    
    
    UILabel *startLabel = [[UILabel alloc] init];
    startLabel.font = [UIFont monospacedSystemFontOfSize:14 weight:UIFontWeightRegular];
    startLabel.textColor = [UIColor blackColor];
    startLabel.numberOfLines = 0;
    startLabel.textAlignment = NSTextAlignmentRight;
    [thin.contentView addSubview:startLabel];
    
    
    [tapLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(thin.contentView).offset(VitalityTab.noneMidMicro.bayerBoxExec);
        make.top.equalTo(thin.contentView).offset(VitalityTab.noneMidMicro.lighterSmall);
        make.bottom.equalTo(thin.contentView).offset(-VitalityTab.noneMidMicro.lighterSmall);
        make.width.equalTo(thin.contentView.mas_width).multipliedBy(binBrief?VitalityTab.noneMidMicro.departureLaw:VitalityTab.noneMidMicro.milesTatarHer);
    }];
    
    [startLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(thin.contentView).offset(-VitalityTab.noneMidMicro.bayerBoxExec);
        make.top.equalTo(thin.contentView).offset(VitalityTab.noneMidMicro.lighterSmall);
        make.bottom.equalTo(thin.contentView).offset(-VitalityTab.noneMidMicro.lighterSmall);
        make.left.equalTo(tapLabel.mas_right).offset(VitalityTab.noneMidMicro.lighterSmall);
    }];
    
    
    if (binBrief) {
        thin.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    } else {
        startLabel.text = [value description];
        thin.accessoryType = UITableViewCellAccessoryNone;
    }
    
    return thin;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    id value;
    NSString *key;
    
    NSInteger privacyIndex = indexPath.section;
    key = _deltaChatOuter[privacyIndex][indexPath.row];
    value = _forbiddenNineRatingsFlipSymptom[privacyIndex][key];
    
    
    if ([value isKindOfClass:[NSDictionary class]]) {
        [self unablePairDictionary:value withTitle:key];
    } else if ([value isKindOfClass:[NSArray class]]) {
        [self smilePowerArray:value withTitle:key];
    } else {
        
        UIPasteboard *angleMetal = [UIPasteboard generalPasteboard];
        [angleMetal setString:[value description]];
        [AnyToast forkAir:VitalityTab.noneMidMicro.foundLatePointerTwoRenewingWin];
    }
}


- (void)unablePairDictionary:(NSDictionary *)lazy withTitle:(NSString *)title {
    NowMapPoolViewController *starRoll = [[NowMapPoolViewController alloc] init];
    [self.navigationController pushViewController:starRoll animated:NO];
    [starRoll eyeFunHisMoreInfo:lazy withTitle:title];
}

- (void)smilePowerArray:(NSArray *)array withTitle:(NSString *)title {
    
    NSMutableDictionary *pauseDict = [NSMutableDictionary dictionary];
    for (NSInteger i = 0; i < array.count; i++) {
        pauseDict[[NSString stringWithFormat:@"[%ld]", (long)i]] = array[i];
    }
    
    NowMapPoolViewController *starRoll = [[NowMapPoolViewController alloc] init];
    [self.navigationController pushViewController:starRoll animated:NO];
    [starRoll eyeFunHisMoreInfo:pauseDict withTitle:[NSString stringWithFormat:@"%@ (Array)", title]];
}

@end
