






#import "CombinedJabberViewController.h"
#import <WebKit/WebKit.h>
#import <WebKit/WKFoundation.h>
#import "NSString+Terabytes.h"
#import "NSString+TwoSinSerif.h"

@interface CombinedJabberViewController ()<UIScrollViewDelegate,WKNavigationDelegate>

@property (nonatomic, strong) UISegmentedControl *trapIodineLinkControl;
@property (nonatomic, strong) UIView * echoEndGuaraniStereoMark;
@property (nonatomic, strong) UIView * affineHelloDisparityPersonNewtons;

@property (nonatomic, strong) UIScrollView * ignoringSubView;

@end

@implementation CombinedJabberViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.rawPinkCarButton.hidden = YES;
    self.pinchHaveButton.hidden = YES;
    
    UISegmentedControl *sawMileView = [[UISegmentedControl alloc] initWithItems:@[VitalityTab.foggyCycleUnit.lowElasticUnifyDependentPashtoFunk,VitalityTab.foggyCycleUnit.unwindProfileConductorAccuracyRoomMild]];
    sawMileView.layer.masksToBounds = YES; 
    sawMileView.layer.cornerRadius = 2;    
    [sawMileView setTitleTextAttributes:@{NSForegroundColorAttributeName:[VitalityTab didCancelColor]} forState:UIControlStateSelected];
    [sawMileView setTitleTextAttributes:@{NSForegroundColorAttributeName:[VitalityTab didCancelColor]} forState:UIControlStateNormal];
    [self.view addSubview:sawMileView];
    [sawMileView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.mas_equalTo(VitalityTab.noneMidMicro.streetApple);
    }];
    [sawMileView addTarget:self action:@selector(heartbeatPast:) forControlEvents:UIControlEventValueChanged];
    self.trapIodineLinkControl = sawMileView;
    
    _ignoringSubView = [[UIScrollView alloc]init];
    _ignoringSubView.pagingEnabled = YES;
    _ignoringSubView.delegate = self;
    [self.view addSubview:_ignoringSubView];
    [_ignoringSubView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(VitalityTab.noneMidMicro.bayerBoxExec);
        make.right.equalTo(self.view).offset(-VitalityTab.noneMidMicro.bayerBoxExec);
        make.top.equalTo(self.view).offset(VitalityTab.noneMidMicro.wetEarIndigo);
        make.bottom.equalTo(self.view).offset(-VitalityTab.noneMidMicro.sockSunClaim);
    }];
    
    UIView *containerView = [UIView new];
    containerView.backgroundColor = UIColor.whiteColor;
    [self.ignoringSubView addSubview:containerView];
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.ignoringSubView);
        make.height.equalTo(_ignoringSubView);
    }];
    
    UIView * howObjectHas = [self showIllTenView:[VitalityTab expertSlopeOfferFeedbackTatar]];
    [containerView addSubview:howObjectHas];
    [howObjectHas mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.bottom.equalTo(containerView);
        make.width.mas_equalTo(self.ignoringSubView);
    }];
    self.echoEndGuaraniStereoMark = howObjectHas;
    
    UIView * faxProtected = [self showIllTenView:[VitalityTab integrateRootLocalTabEast]];
    [containerView addSubview:faxProtected];
    [faxProtected mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(howObjectHas.mas_right);
        make.bottom.top.equalTo(containerView);
        make.width.mas_equalTo(self.ignoringSubView);
    }];
    self.affineHelloDisparityPersonNewtons = faxProtected;
    
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(faxProtected.mas_right);
    }];
    
    if (![self.moleShotRaw boolValue]) {
        UIButton *midYearButton = [VitalityTab cousinAlertRomanVibrancyIdleColor:VitalityTab.foggyCycleUnit.magnesiumTwo];
        [midYearButton setBackgroundImage:[UIImage barWasSeeRoundColor:[[UIColor lightGrayColor] colorWithAlphaComponent:0.5f]] forState:UIControlStateNormal];
        [midYearButton addTarget:self action:@selector(ejectLiveStormPrefixDescribeStyle:) forControlEvents:(UIControlEventTouchUpInside)];
        [self.view addSubview:midYearButton];
        [midYearButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.view).offset(-VitalityTab.noneMidMicro.rowsNoneLow);
            make.centerX.equalTo(self.view).multipliedBy(.65);
            make.height.mas_equalTo(VitalityTab.noneMidMicro.basalHairMid);
        }];
    }
    
    UIButton *napPoolButton =  [VitalityTab cousinAlertRomanVibrancyIdleColor:VitalityTab.foggyCycleUnit.mouseToken];
    [napPoolButton addTarget:self action:@selector(issuerLinkBarDrizzleStoodDark:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:napPoolButton];
    [napPoolButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view).offset(-VitalityTab.noneMidMicro.rowsNoneLow);
        make.centerX.equalTo(self.view).multipliedBy(![self.moleShotRaw boolValue]?1.35:1);
        make.height.mas_equalTo(VitalityTab.noneMidMicro.basalHairMid);
    }];
    
    sawMileView.selectedSegmentIndex = 0;
    [self heartbeatPast:sawMileView];
}

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

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

- (void)uppercaseCommitHasJabberIconText:(NSInteger)type {
    NSString *nextEarDry = nil;
    UIView *contentView = nil;
    nextEarDry = type == 0 ? [VitalityTab expertSlopeOfferFeedbackTatar]:[VitalityTab integrateRootLocalTabEast];
    contentView = type == 0 ? self.echoEndGuaraniStereoMark:self.affineHelloDisparityPersonNewtons;
    
    if (nextEarDry.alertGetSolo) {
        return;
    }
    
    if ([[nextEarDry pathExtension] containsString:VitalityTab.noneMidMicro.hisUpdatingKilogramBetweenAddition]) {
        UITextView *canView = (UITextView *)contentView;
        if (canView.text.length > 0) {
            return;
        }

        
        [CommitBikeView constantsPlugView:contentView];

        
        NSURL *url = [NSURL URLWithString:nextEarDry];
        NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:url
                                                                 completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
            
            dispatch_async(dispatch_get_main_queue(), ^{
                
                [CommitBikeView pointMagnitudeReceiptDiscoverYetView:contentView];
                
                if (error || data.length == 0) {
                    
                    canView.text = VitalityTab.foggyCycleUnit.appendFlashConstructKilobitsIssueFree;
                    return;
                }
                
                
                NSString *fixTagEastKey = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
                canView.text = fixTagEastKey ?: VitalityTab.foggyCycleUnit.languageStrokingIndexAlienObserverPerfusionReject;
            });
        }];
        
        [task resume];

    }else {
        WKWebView *sticky = (WKWebView *)contentView;
        if (!sticky.isLoading && sticky.estimatedProgress == 1) {
            [CommitBikeView pointMagnitudeReceiptDiscoverYetView:contentView];
            return;
        }
        [CommitBikeView constantsPlugView:contentView];
        NSString *caseFloor =  [nextEarDry.submitSomaliLossLastLayerSensitive stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
        NSURL *url = [NSURL URLWithString:caseFloor];
        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:15.0];
        [sticky loadRequest:request];
    }
}

- (void)ejectLiveStormPrefixDescribeStyle:(id)sender {
    [self utteranceSomaliOfferRowChannelAction:nil];
    if (self.netscapeRegionKilovoltsSeparatorResolving) {
        self.netscapeRegionKilovoltsSeparatorResolving(NO);
    }
}

- (void)issuerLinkBarDrizzleStoodDark:(id)sender {
    [self utteranceSomaliOfferRowChannelAction:nil];
    if (self.netscapeRegionKilovoltsSeparatorResolving) {
        self.netscapeRegionKilovoltsSeparatorResolving(YES);
    }
}

- (UIView *)showIllTenView:(NSString *)string {
    UIView *outBigOwner = nil;
    if ([[string pathExtension] containsString:VitalityTab.noneMidMicro.hisUpdatingKilogramBetweenAddition]) {
        UITextView * ruleLoad = [UITextView new];
        ruleLoad.editable = NO;
        ruleLoad.backgroundColor = UIColor.whiteColor;
        ruleLoad.textColor = UIColor.grayColor;
        outBigOwner = ruleLoad;
    }else {
        WKWebView *finalizeTap = [[WKWebView alloc] initWithFrame:CGRectZero];
        finalizeTap.backgroundColor = UIColor.clearColor;
        finalizeTap.scrollView.backgroundColor = UIColor.lightGrayColor;
        finalizeTap.opaque = YES;
        finalizeTap.scrollView.bounces =NO;
        finalizeTap.scrollView.showsVerticalScrollIndicator = NO;
        finalizeTap.scrollView.showsHorizontalScrollIndicator = NO;
        finalizeTap.navigationDelegate = self;
        outBigOwner = finalizeTap;
    }
    return outBigOwner;
}

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

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear: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);
    }];
}

@end
