






#import "YetKernelsViewController.h"
#import "IllNumbersConfig.h"
#import "NSObject+SpaModel.h"
#import "UIColor+NotColor.h"
#import "MidToast.h"

@interface YetKernelsViewController ()<UITableViewDataSource, UITableViewDelegate>

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

@end

@implementation YetKernelsViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    _persistOffSortLegacyAnchors = [NSMutableArray array];
    _scanAnyBandTap = @[];
    _sectionTitles = [NSMutableArray array];
    
    [self futureClipView];
}

- (void)viewWillAppear:(BOOL)animated {
    
    UIEdgeInsets mathAndIcy = [[MatchMenuManager shared] teacherDepthWindow].safeAreaInsets;
    
    mathAndIcy.top    += 10;
    mathAndIcy.left   += 10;
    mathAndIcy.bottom += 10;
    mathAndIcy.right  += 10;

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


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


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

- (void)putDryInsulinInfo:(NSDictionary *)info withTitle:(NSString *)title {
    if (!info || ![info isKindOfClass:[NSDictionary class]]) {
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        @synchronized (self) {
            
            [self->_persistOffSortLegacyAnchors addObject:[info copy]];
            NSArray *keyOutDrag = [self clockThreeEchoDictionary:info];
            self->_scanAnyBandTap = [self->_scanAnyBandTap arrayByAddingObject:keyOutDrag];
            [self->_sectionTitles addObject:title];
            
            
            [self.tableView reloadData];
        }
    });
}


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

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

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

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *slow = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass(self.class) forIndexPath:indexPath];
    
    NSString *key;
    id value;
    NSInteger execSobIndex = indexPath.section;
    key = _scanAnyBandTap[execSobIndex][indexPath.row];
    value = _persistOffSortLegacyAnchors[execSobIndex][key];
    BOOL eyeBasic = [value isKindOfClass:[NSDictionary class]] || [value isKindOfClass:[NSArray class]];
    slow.backgroundColor = [UIColor clearColor];
    
    
    for (UIView *corrupt in slow.contentView.subviews) {
        [corrupt removeFromSuperview];
    }
    
    
    UILabel *rawLabel = [[UILabel alloc] init];
    rawLabel.font = [UIFont monospacedSystemFontOfSize:14 weight:UIFontWeightMedium];
    rawLabel.textColor = [UIColor darkGrayColor];
    rawLabel.text = key;
    rawLabel.numberOfLines = 0;
    [slow.contentView addSubview:rawLabel];
    
    
    UILabel *molarLabel = [[UILabel alloc] init];
    molarLabel.font = [UIFont monospacedSystemFontOfSize:14 weight:UIFontWeightRegular];
    molarLabel.textColor = [UIColor blackColor];
    molarLabel.numberOfLines = 0;
    molarLabel.textAlignment = NSTextAlignmentRight;
    [slow.contentView addSubview:molarLabel];
    
    
    [rawLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(slow.contentView).offset(UserArtRoot.wayAbortLove.takePubLarge);
        make.top.equalTo(slow.contentView).offset(UserArtRoot.wayAbortLove.panGreenSpan);
        make.bottom.equalTo(slow.contentView).offset(-UserArtRoot.wayAbortLove.panGreenSpan);
        make.width.equalTo(slow.contentView.mas_width).multipliedBy(eyeBasic?UserArtRoot.wayAbortLove.poloCanPiece:UserArtRoot.wayAbortLove.kashmiriExits);
    }];
    
    [molarLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(slow.contentView).offset(-UserArtRoot.wayAbortLove.takePubLarge);
        make.top.equalTo(slow.contentView).offset(UserArtRoot.wayAbortLove.panGreenSpan);
        make.bottom.equalTo(slow.contentView).offset(-UserArtRoot.wayAbortLove.panGreenSpan);
        make.left.equalTo(rawLabel.mas_right).offset(UserArtRoot.wayAbortLove.panGreenSpan);
    }];
    
    
    if (eyeBasic) {
        slow.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    } else {
        molarLabel.text = [value description];
        slow.accessoryType = UITableViewCellAccessoryNone;
    }
    
    return slow;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    id value;
    NSString *key;
    
    NSInteger execSobIndex = indexPath.section;
    key = _scanAnyBandTap[execSobIndex][indexPath.row];
    value = _persistOffSortLegacyAnchors[execSobIndex][key];
    
    
    if ([value isKindOfClass:[NSDictionary class]]) {
        [self didBodySayDictionary:value withTitle:key];
    } else if ([value isKindOfClass:[NSArray class]]) {
        [self audioPhoneArray:value withTitle:key];
    } else {
        
        UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
        [pasteboard setString:[value description]];
        [MidToast adjusts:UserArtRoot.wayAbortLove.sinImmutableAreActivityDaysDiscover];
    }
}


- (void)didBodySayDictionary:(NSDictionary *)many withTitle:(NSString *)title {
    YetKernelsViewController *datumEra = [[YetKernelsViewController alloc] init];
    [self.navigationController pushViewController:datumEra animated:NO];
    [datumEra putDryInsulinInfo:many withTitle:title];
}

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

@end
