






#import "ExecSpellBoundViewController.h"
#import <WebKit/WebKit.h>
#import <WebKit/WKFoundation.h>
#import "NSString+Connected.h"
#import "NSString+PortMeasure.h"

@interface ExecSpellBoundViewController ()<UIScrollViewDelegate,WKNavigationDelegate>

@property (nonatomic, strong) UISegmentedControl *daysSolveRoundControl;
@property (nonatomic, strong) UIView * sentinelDarkerKeepHebrewVolume;
@property (nonatomic, strong) UIView * revisionsReadableProvidesAffinityCoalesced;

@property (nonatomic, strong) UIScrollView * escapeSwipeView;

@end

@implementation ExecSpellBoundViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.waistAfterButton.hidden = YES;
    self.formatIllButton.hidden = YES;
    
    UISegmentedControl *messageView = [[UISegmentedControl alloc] initWithItems:@[TopMergeNap.turnFoggyPivot.rateAlphaOfferSpringSuspendedVariation,TopMergeNap.turnFoggyPivot.vibrancySayQuotesCiphersNoneCalories]];
    messageView.layer.masksToBounds = YES; 
    messageView.layer.cornerRadius = 2;    
    [messageView setTitleTextAttributes:@{NSForegroundColorAttributeName:[TopMergeNap variationColor]} forState:UIControlStateSelected];
    [messageView setTitleTextAttributes:@{NSForegroundColorAttributeName:[TopMergeNap variationColor]} forState:UIControlStateNormal];
    [self.view addSubview:messageView];
    [messageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.mas_equalTo(TopMergeNap.yetChromaUse.illCatBrown);
    }];
    [messageView addTarget:self action:@selector(ephemeralPong:) forControlEvents:UIControlEventValueChanged];
    self.daysSolveRoundControl = messageView;
    
    _escapeSwipeView = [[UIScrollView alloc]init];
    _escapeSwipeView.pagingEnabled = YES;
    _escapeSwipeView.delegate = self;
    [self.view addSubview:_escapeSwipeView];
    [_escapeSwipeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(TopMergeNap.yetChromaUse.dogIterative);
        make.right.equalTo(self.view).offset(-TopMergeNap.yetChromaUse.dogIterative);
        make.top.equalTo(self.view).offset(TopMergeNap.yetChromaUse.scopeSizeArm);
        make.bottom.equalTo(self.view).offset(-TopMergeNap.yetChromaUse.deleteSecure);
    }];
    
    UIView *containerView = [UIView new];
    containerView.backgroundColor = UIColor.whiteColor;
    [self.escapeSwipeView addSubview:containerView];
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.escapeSwipeView);
        make.height.equalTo(_escapeSwipeView);
    }];
    
    UIView * atomWasTrack = [self anyFlippedView:[TopMergeNap webpageAutomaticBasicSettlingOxygen]];
    [containerView addSubview:atomWasTrack];
    [atomWasTrack mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.bottom.equalTo(containerView);
        make.width.mas_equalTo(self.escapeSwipeView);
    }];
    self.sentinelDarkerKeepHebrewVolume = atomWasTrack;
    
    UIView * waistReceipt = [self anyFlippedView:[TopMergeNap executeReusePrintedSpellCross]];
    [containerView addSubview:waistReceipt];
    [waistReceipt mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(atomWasTrack.mas_right);
        make.bottom.top.equalTo(containerView);
        make.width.mas_equalTo(self.escapeSwipeView);
    }];
    self.revisionsReadableProvidesAffinityCoalesced = waistReceipt;
    
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(waistReceipt.mas_right);
    }];
    
    if (![self.fullDustPan boolValue]) {
        UIButton *forSinkButton = [TopMergeNap shutterFarsiSeparatorMolarFactColor:TopMergeNap.turnFoggyPivot.musicalWrite];
        [forSinkButton setBackgroundImage:[UIImage allIdleSpanWetColor:[[UIColor lightGrayColor] colorWithAlphaComponent:0.5f]] forState:UIControlStateNormal];
        [forSinkButton addTarget:self action:@selector(putRainFormatSequencerTrailingPub:) forControlEvents:(UIControlEventTouchUpInside)];
        [self.view addSubview:forSinkButton];
        [forSinkButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.view).offset(-TopMergeNap.yetChromaUse.knowSayChat);
            make.centerX.equalTo(self.view).multipliedBy(.65);
            make.height.mas_equalTo(TopMergeNap.yetChromaUse.everyContain);
        }];
    }
    
    UIButton *areaWinButton =  [TopMergeNap shutterFarsiSeparatorMolarFactColor:TopMergeNap.turnFoggyPivot.smallValue];
    [areaWinButton addTarget:self action:@selector(objectEndMajorSunEighteenHeartbeat:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:areaWinButton];
    [areaWinButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view).offset(-TopMergeNap.yetChromaUse.knowSayChat);
        make.centerX.equalTo(self.view).multipliedBy(![self.fullDustPan boolValue]?1.35:1);
        make.height.mas_equalTo(TopMergeNap.yetChromaUse.everyContain);
    }];
    
    messageView.selectedSegmentIndex = 0;
    [self ephemeralPong:messageView];
}

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

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

- (void)tallFourthDownSupportsRenameText:(NSInteger)type {
    NSString *archiveDay = nil;
    UIView *contentView = nil;
    archiveDay = type == 0 ? [TopMergeNap webpageAutomaticBasicSettlingOxygen]:[TopMergeNap executeReusePrintedSpellCross];
    contentView = type == 0 ? self.sentinelDarkerKeepHebrewVolume:self.revisionsReadableProvidesAffinityCoalesced;
    
    if (archiveDay.unitSmoothed) {
        return;
    }
    
    if ([[archiveDay pathExtension] containsString:TopMergeNap.yetChromaUse.periodicHangSleetBikeFit]) {
        UITextView *boxView = (UITextView *)contentView;
        if (boxView.text.length > 0) {
            return;
        }

        
        [BankBorderView saveChestMathView:contentView];

        
        NSURL *url = [NSURL URLWithString:archiveDay];
        NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:url
                                                                 completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
            
            dispatch_async(dispatch_get_main_queue(), ^{
                
                [BankBorderView fourDisplaySmoothUnionIndicatorView:contentView];
                
                if (error || data.length == 0) {
                    
                    boxView.text = TopMergeNap.turnFoggyPivot.rankedIndexAbnormalBleedKilohertzDemand;
                    return;
                }
                
                
                NSString *loopNotifying = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
                boxView.text = loopNotifying ?: TopMergeNap.turnFoggyPivot.lowInferiorsFormattedStreetGenericsTexturedBoundary;
            });
        }];
        
        [task resume];

    }else {
        WKWebView *weekly = (WKWebView *)contentView;
        if (!weekly.isLoading && weekly.estimatedProgress == 1) {
            [BankBorderView fourDisplaySmoothUnionIndicatorView:contentView];
            return;
        }
        [BankBorderView saveChestMathView:contentView];
        NSString *moleHover =  [archiveDay.spacingHeapFitStrongExitsButterfly stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
        NSURL *url = [NSURL URLWithString:moleHover];
        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:15.0];
        [weekly loadRequest:request];
    }
}

- (void)putRainFormatSequencerTrailingPub:(id)sender {
    [self kinEngineerSerializeSingleResizeAction:nil];
    if (self.unlimitedFixDuplicatePrincipalCompleted) {
        self.unlimitedFixDuplicatePrincipalCompleted(NO);
    }
}

- (void)objectEndMajorSunEighteenHeartbeat:(id)sender {
    [self kinEngineerSerializeSingleResizeAction:nil];
    if (self.unlimitedFixDuplicatePrincipalCompleted) {
        self.unlimitedFixDuplicatePrincipalCompleted(YES);
    }
}

- (UIView *)anyFlippedView:(NSString *)string {
    UIView *butCertHost = nil;
    if ([[string pathExtension] containsString:TopMergeNap.yetChromaUse.periodicHangSleetBikeFit]) {
        UITextView * itemGray = [UITextView new];
        itemGray.editable = NO;
        itemGray.backgroundColor = UIColor.whiteColor;
        itemGray.textColor = UIColor.grayColor;
        butCertHost = itemGray;
    }else {
        WKWebView *legalActive = [[WKWebView alloc] initWithFrame:CGRectZero];
        legalActive.backgroundColor = UIColor.clearColor;
        legalActive.scrollView.backgroundColor = UIColor.lightGrayColor;
        legalActive.opaque = YES;
        legalActive.scrollView.bounces =NO;
        legalActive.scrollView.showsVerticalScrollIndicator = NO;
        legalActive.scrollView.showsHorizontalScrollIndicator = NO;
        legalActive.navigationDelegate = self;
        butCertHost = legalActive;
    }
    return butCertHost;
}

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

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

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

@end
