






#import "PaperSlidePathViewController.h"
#import <WebKit/WebKit.h>
#import <WebKit/WKFoundation.h>
#import "NSString+ReturnHow.h"
#import "NSString+FadeFeatDid.h"

@interface PaperSlidePathViewController ()<UIScrollViewDelegate,WKNavigationDelegate>

@property (nonatomic, strong) UISegmentedControl *partStickyFeetControl;
@property (nonatomic, strong) UIView * yetSortNothingSameBuffered;
@property (nonatomic, strong) UIView * genericsSnapBurstSubmittedSingle;

@property (nonatomic, strong) UIScrollView * menLogoTaskView;

@end

@implementation PaperSlidePathViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.magicPieceButton.hidden = YES;
    self.barFusionButton.hidden = YES;
    
    UISegmentedControl *millionView = [[UISegmentedControl alloc] initWithItems:@[HisGeometry.illLoudEarFlow.postalBrowsePriorAcrossAllBattery,HisGeometry.illLoudEarFlow.parentalEndHaveCubeAdjustingJustified]];
    millionView.layer.masksToBounds = YES; 
    millionView.layer.cornerRadius = 2;    
    [millionView setTitleTextAttributes:@{NSForegroundColorAttributeName:[HisGeometry schedulerColor]} forState:UIControlStateSelected];
    [millionView setTitleTextAttributes:@{NSForegroundColorAttributeName:[HisGeometry schedulerColor]} forState:UIControlStateNormal];
    [self.view addSubview:millionView];
    [millionView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.mas_equalTo(HisGeometry.sinkIcyLeaky.unsafeLoose);
    }];
    [millionView addTarget:self action:@selector(sonSubLookCut:) forControlEvents:UIControlEventValueChanged];
    self.partStickyFeetControl = millionView;
    
    _menLogoTaskView = [[UIScrollView alloc]init];
    _menLogoTaskView.pagingEnabled = YES;
    _menLogoTaskView.delegate = self;
    [self.view addSubview:_menLogoTaskView];
    [_menLogoTaskView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(HisGeometry.sinkIcyLeaky.sleepBestTab);
        make.right.equalTo(self.view).offset(-HisGeometry.sinkIcyLeaky.sleepBestTab);
        make.top.equalTo(self.view).offset(HisGeometry.sinkIcyLeaky.wordTagMiter);
        make.bottom.equalTo(self.view).offset(-HisGeometry.sinkIcyLeaky.hallNotVisit);
    }];
    
    UIView *containerView = [UIView new];
    containerView.backgroundColor = UIColor.whiteColor;
    [self.menLogoTaskView addSubview:containerView];
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.menLogoTaskView);
        make.height.equalTo(_menLogoTaskView);
    }];
    
    UIView * binPotassium = [self flagSpokenView:[HisGeometry stopLinkageEntitledBufferedVignette]];
    [containerView addSubview:binPotassium];
    [binPotassium mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.bottom.equalTo(containerView);
        make.width.mas_equalTo(self.menLogoTaskView);
    }];
    self.yetSortNothingSameBuffered = binPotassium;
    
    UIView * foodIcyHindi = [self flagSpokenView:[HisGeometry familyBookEnsureIntentTelephone]];
    [containerView addSubview:foodIcyHindi];
    [foodIcyHindi mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(binPotassium.mas_right);
        make.bottom.top.equalTo(containerView);
        make.width.mas_equalTo(self.menLogoTaskView);
    }];
    self.genericsSnapBurstSubmittedSingle = foodIcyHindi;
    
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(foodIcyHindi.mas_right);
    }];
    
    if (![self.crossActive boolValue]) {
        UIButton *spousesButton = [HisGeometry momentaryQueryingTryExclusiveSamplingColor:HisGeometry.illLoudEarFlow.selectingYet];
        [spousesButton setBackgroundImage:[UIImage slabItsArtCostColor:[[UIColor lightGrayColor] colorWithAlphaComponent:0.5f]] forState:UIControlStateNormal];
        [spousesButton addTarget:self action:@selector(compressRepeatGaspVerifyFourthRoute:) forControlEvents:(UIControlEventTouchUpInside)];
        [self.view addSubview:spousesButton];
        [spousesButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.view).offset(-HisGeometry.sinkIcyLeaky.capsPlayOff);
            make.centerX.equalTo(self.view).multipliedBy(.65);
            make.height.mas_equalTo(HisGeometry.sinkIcyLeaky.subjectQuery);
        }];
    }
    
    UIButton *youPinkButton =  [HisGeometry momentaryQueryingTryExclusiveSamplingColor:HisGeometry.illLoudEarFlow.pageTopPen];
    [youPinkButton addTarget:self action:@selector(artsRedefinedGeorgianParseMegahertzPriority:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:youPinkButton];
    [youPinkButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view).offset(-HisGeometry.sinkIcyLeaky.capsPlayOff);
        make.centerX.equalTo(self.view).multipliedBy(![self.crossActive boolValue]?1.35:1);
        make.height.mas_equalTo(HisGeometry.sinkIcyLeaky.subjectQuery);
    }];
    
    millionView.selectedSegmentIndex = 0;
    [self sonSubLookCut:millionView];
}

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    [self.partStickyFeetControl setSelectedSegmentIndex:scrollView.contentOffset.x/self.view.frame.size.width ==0?0:1];
    [self hexPashtoPressAskSnowText:scrollView.contentOffset.x/self.view.frame.size.width ==0?0:1];
}

- (void)sonSubLookCut:(UISegmentedControl *)sender {
    [self hexPashtoPressAskSnowText:sender.selectedSegmentIndex == 0?0:1];
    [self.menLogoTaskView setContentOffset:CGPointMake(sender.selectedSegmentIndex == 0?0:self.menLogoTaskView.frame.size.width, 0) animated:YES];
}

- (void)hexPashtoPressAskSnowText:(NSInteger)type {
    NSString *entropyBad = nil;
    UIView *contentView = nil;
    entropyBad = type == 0 ? [HisGeometry stopLinkageEntitledBufferedVignette]:[HisGeometry familyBookEnsureIntentTelephone];
    contentView = type == 0 ? self.yetSortNothingSameBuffered:self.genericsSnapBurstSubmittedSingle;
    
    if (entropyBad.pubFlushNear) {
        return;
    }
    
    if ([[entropyBad pathExtension] containsString:HisGeometry.sinkIcyLeaky.ownerAndFunnelArtworkCoalesce]) {
        UITextView *funView = (UITextView *)contentView;
        if (funView.text.length > 0) {
            return;
        }

        
        [OldestSnowView moodSuggestedView:contentView];

        
        NSURL *url = [NSURL URLWithString:entropyBad];
        NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:url
                                                                 completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
            
            dispatch_async(dispatch_get_main_queue(), ^{
                
                [OldestSnowView bundlesExecKilohertzRulePerformedView:contentView];
                
                if (error || data.length == 0) {
                    
                    funView.text = HisGeometry.illLoudEarFlow.documentSuggestRevertingProminentClimbingSolid;
                    return;
                }
                
                
                NSString *oneDecoderRow = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
                funView.text = oneDecoderRow ?: HisGeometry.illLoudEarFlow.deciliterNominalMeterUndoSlideFeedbackWhile;
            });
        }];
        
        [task resume];

    }else {
        WKWebView *sayCan = (WKWebView *)contentView;
        if (!sayCan.isLoading && sayCan.estimatedProgress == 1) {
            [OldestSnowView bundlesExecKilohertzRulePerformedView:contentView];
            return;
        }
        [OldestSnowView moodSuggestedView:contentView];
        NSString *slideRate =  [entropyBad.definesPenKindCapturedPrematureFit stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
        NSURL *url = [NSURL URLWithString:slideRate];
        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:15.0];
        [sayCan loadRequest:request];
    }
}

- (void)compressRepeatGaspVerifyFourthRoute:(id)sender {
    [self factoredQuotationInsetChangingCarAction:nil];
    if (self.templateAssetInterlacePreservedStar) {
        self.templateAssetInterlacePreservedStar(NO);
    }
}

- (void)artsRedefinedGeorgianParseMegahertzPriority:(id)sender {
    [self factoredQuotationInsetChangingCarAction:nil];
    if (self.templateAssetInterlacePreservedStar) {
        self.templateAssetInterlacePreservedStar(YES);
    }
}

- (UIView *)flagSpokenView:(NSString *)string {
    UIView *gopherQueue = nil;
    if ([[string pathExtension] containsString:HisGeometry.sinkIcyLeaky.ownerAndFunnelArtworkCoalesce]) {
        UITextView * dustPort = [UITextView new];
        dustPort.editable = NO;
        dustPort.backgroundColor = UIColor.whiteColor;
        dustPort.textColor = UIColor.grayColor;
        gopherQueue = dustPort;
    }else {
        WKWebView *sonMaxExtra = [[WKWebView alloc] initWithFrame:CGRectZero];
        sonMaxExtra.backgroundColor = UIColor.clearColor;
        sonMaxExtra.scrollView.backgroundColor = UIColor.lightGrayColor;
        sonMaxExtra.opaque = YES;
        sonMaxExtra.scrollView.bounces =NO;
        sonMaxExtra.scrollView.showsVerticalScrollIndicator = NO;
        sonMaxExtra.scrollView.showsHorizontalScrollIndicator = NO;
        sonMaxExtra.navigationDelegate = self;
        gopherQueue = sonMaxExtra;
    }
    return gopherQueue;
}

- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
    [OldestSnowView bundlesExecKilohertzRulePerformedView:webView];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    UIEdgeInsets boxTheMore = [[FarEntityManager shared] joinProducesWindow].safeAreaInsets;
    boxTheMore.top    += 10;
    boxTheMore.left   += 10;
    boxTheMore.bottom += 10;
    boxTheMore.right  += 10;

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

@end
