






#import "IllPathPubViewController.h"
#import "TagBinRealConfig.h"
#import "NSObject+ButModel.h"
#import "UIColor+KitColor.h"
#import "MidToast.h"

@interface IllPathPubViewController ()<UITableViewDataSource, UITableViewDelegate>

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

@end

@implementation IllPathPubViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    _guaraniBasicUsedCapturingModify = [NSMutableArray array];
    _stoneLiterStep = @[];
    _sectionTitles = [NSMutableArray array];
    
    [self eyeIcySwapView];
}

- (void)viewWillAppear:(BOOL)animated {
    
    UIEdgeInsets pintBarEra = [[ShearPeakManager shared] netTripleLawWindow].safeAreaInsets;
    
    pintBarEra.top    += 10;
    pintBarEra.left   += 10;
    pintBarEra.bottom += 10;
    pintBarEra.right  += 10;

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


- (void)eyeIcySwapView {
    _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.semicolonButton.mas_bottom);
        make.left.right.bottom.equalTo(self.view);
    }];
    
    
    [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:NSStringFromClass(self.class)];
}


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

- (void)spaTagBlobSumInfo:(NSDictionary *)info withTitle:(NSString *)title {
    if (!info || ![info isKindOfClass:[NSDictionary class]]) {
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        @synchronized (self) {
            
            [self->_guaraniBasicUsedCapturingModify addObject:[info copy]];
            NSArray *bottomPull = [self mindJobSnowMixDictionary:info];
            self->_stoneLiterStep = [self->_stoneLiterStep arrayByAddingObject:bottomPull];
            [self->_sectionTitles addObject:title];
            
            
            [self.tableView reloadData];
        }
    });
}


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

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

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

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *pace = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass(self.class) forIndexPath:indexPath];
    
    NSString *key;
    id value;
    NSInteger earDeepIndex = indexPath.section;
    key = _stoneLiterStep[earDeepIndex][indexPath.row];
    value = _guaraniBasicUsedCapturingModify[earDeepIndex][key];
    BOOL tertiary = [value isKindOfClass:[NSDictionary class]] || [value isKindOfClass:[NSArray class]];
    pace.backgroundColor = [UIColor clearColor];
    
    
    for (UIView *dispose in pace.contentView.subviews) {
        [dispose removeFromSuperview];
    }
    
    
    UILabel *icyLabel = [[UILabel alloc] init];
    icyLabel.font = [UIFont monospacedSystemFontOfSize:14 weight:UIFontWeightMedium];
    icyLabel.textColor = [UIColor darkGrayColor];
    icyLabel.text = key;
    icyLabel.numberOfLines = 0;
    [pace.contentView addSubview:icyLabel];
    
    
    UILabel *pulseLabel = [[UILabel alloc] init];
    pulseLabel.font = [UIFont monospacedSystemFontOfSize:14 weight:UIFontWeightRegular];
    pulseLabel.textColor = [UIColor blackColor];
    pulseLabel.numberOfLines = 0;
    pulseLabel.textAlignment = NSTextAlignmentRight;
    [pace.contentView addSubview:pulseLabel];
    
    
    [icyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(pace.contentView).offset(NapEscaping.restoringWay.poloSecurity);
        make.top.equalTo(pace.contentView).offset(NapEscaping.restoringWay.putGradeHand);
        make.bottom.equalTo(pace.contentView).offset(-NapEscaping.restoringWay.putGradeHand);
        make.width.equalTo(pace.contentView.mas_width).multipliedBy(tertiary?NapEscaping.restoringWay.tenOptHidden:NapEscaping.restoringWay.addKitUseTrap);
    }];
    
    [pulseLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(pace.contentView).offset(-NapEscaping.restoringWay.poloSecurity);
        make.top.equalTo(pace.contentView).offset(NapEscaping.restoringWay.putGradeHand);
        make.bottom.equalTo(pace.contentView).offset(-NapEscaping.restoringWay.putGradeHand);
        make.left.equalTo(icyLabel.mas_right).offset(NapEscaping.restoringWay.putGradeHand);
    }];
    
    
    if (tertiary) {
        pace.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    } else {
        pulseLabel.text = [value description];
        pace.accessoryType = UITableViewCellAccessoryNone;
    }
    
    return pace;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    id value;
    NSString *key;
    
    NSInteger earDeepIndex = indexPath.section;
    key = _stoneLiterStep[earDeepIndex][indexPath.row];
    value = _guaraniBasicUsedCapturingModify[earDeepIndex][key];
    
    
    if ([value isKindOfClass:[NSDictionary class]]) {
        [self countEvictDictionary:value withTitle:key];
    } else if ([value isKindOfClass:[NSArray class]]) {
        [self heapEntityArray:value withTitle:key];
    } else {
        
        UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
        [pasteboard setString:[value description]];
        [MidToast outUses:NapEscaping.restoringWay.designerStepsonSubMailPhraseTwo];
    }
}


- (void)countEvictDictionary:(NSDictionary *)face withTitle:(NSString *)title {
    IllPathPubViewController *butScope = [[IllPathPubViewController alloc] init];
    [self.navigationController pushViewController:butScope animated:NO];
    [butScope spaTagBlobSumInfo:face withTitle:title];
}

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

@end
