






#import "OptionMealOnceViewController.h"
#import <WebKit/WebKit.h>
#import <WebKit/WKFoundation.h>
#import "NSString+Redirects.h"
#import "NSString+EggStyleTap.h"

@interface OptionMealOnceViewController ()<UIScrollViewDelegate,WKNavigationDelegate>

@property (nonatomic, strong) UISegmentedControl *sunDrySunLeaseControl;
@property (nonatomic, strong) UIView * editorDecodingDocumentsOffPresence;
@property (nonatomic, strong) UIView * oddWasLeadRootDue;

@property (nonatomic, strong) UIScrollView * wasAllScopeView;

@end

@implementation OptionMealOnceViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.anyDisplayButton.hidden = YES;
    self.protocolsButton.hidden = YES;
    
    UISegmentedControl *beatMixView = [[UISegmentedControl alloc] initWithItems:@[DistantEach.earMayTopModel.signSmallestGrowOddLawDraw,DistantEach.earMayTopModel.fiberCupBurnAlwaysExpertDaily]];
    beatMixView.layer.masksToBounds = YES; 
    beatMixView.layer.cornerRadius = 2;    
    [beatMixView setTitleTextAttributes:@{NSForegroundColorAttributeName:[DistantEach tildePastColor]} forState:UIControlStateSelected];
    [beatMixView setTitleTextAttributes:@{NSForegroundColorAttributeName:[DistantEach tildePastColor]} forState:UIControlStateNormal];
    [self.view addSubview:beatMixView];
    [beatMixView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.mas_equalTo(DistantEach.whoFrenchMin.wireMenGolf);
    }];
    [beatMixView addTarget:self action:@selector(eulerProgress:) forControlEvents:UIControlEventValueChanged];
    self.sunDrySunLeaseControl = beatMixView;
    
    _wasAllScopeView = [[UIScrollView alloc]init];
    _wasAllScopeView.pagingEnabled = YES;
    _wasAllScopeView.delegate = self;
    [self.view addSubview:_wasAllScopeView];
    [_wasAllScopeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(DistantEach.whoFrenchMin.responderPop);
        make.right.equalTo(self.view).offset(-DistantEach.whoFrenchMin.responderPop);
        make.top.equalTo(self.view).offset(DistantEach.whoFrenchMin.collectorMax);
        make.bottom.equalTo(self.view).offset(-DistantEach.whoFrenchMin.gigahertzRed);
    }];
    
    UIView *containerView = [UIView new];
    containerView.backgroundColor = UIColor.whiteColor;
    [self.wasAllScopeView addSubview:containerView];
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.wasAllScopeView);
        make.height.equalTo(_wasAllScopeView);
    }];
    
    UIView * popStayClang = [self delayedEndView:[DistantEach thatPrivilegeSlabOperatingSlavic]];
    [containerView addSubview:popStayClang];
    [popStayClang mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.bottom.equalTo(containerView);
        make.width.mas_equalTo(self.wasAllScopeView);
    }];
    self.editorDecodingDocumentsOffPresence = popStayClang;
    
    UIView * hoverDayTake = [self delayedEndView:[DistantEach catMindVerifyConfirmBrand]];
    [containerView addSubview:hoverDayTake];
    [hoverDayTake mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(popStayClang.mas_right);
        make.bottom.top.equalTo(containerView);
        make.width.mas_equalTo(self.wasAllScopeView);
    }];
    self.oddWasLeadRootDue = hoverDayTake;
    
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(hoverDayTake.mas_right);
    }];
    
    if (![self.barsOptSpan boolValue]) {
        UIButton *alcoholButton = [DistantEach pongLocalExpiresEndBitColor:DistantEach.earMayTopModel.busyStoodBig];
        [alcoholButton setBackgroundImage:[UIImage outDelayItsTenColor:[[UIColor lightGrayColor] colorWithAlphaComponent:0.5f]] forState:UIControlStateNormal];
        [alcoholButton addTarget:self action:@selector(historyButBundleSplitSnapSkipped:) forControlEvents:(UIControlEventTouchUpInside)];
        [self.view addSubview:alcoholButton];
        
        [alcoholButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.view).offset(-DistantEach.whoFrenchMin.getWarnLost);
            make.left.equalTo(self.view).offset(DistantEach.whoFrenchMin.responderPop);
            make.right.equalTo(self.view.mas_centerX).offset(-DistantEach.whoFrenchMin.scoreTriple);
            make.height.mas_equalTo(DistantEach.whoFrenchMin.eggGathering);
        }];
    }

    UIButton *pathYouButton =  [DistantEach pongLocalExpiresEndBitColor:DistantEach.earMayTopModel.sexBuilder];
    [pathYouButton addTarget:self action:@selector(localizesFallbackTomorrowDiacriticCousinAny:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:pathYouButton];
    BOOL matchButton = ![self.barsOptSpan boolValue];
    [pathYouButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view).offset(-DistantEach.whoFrenchMin.getWarnLost);
        make.right.equalTo(self.view).offset(-DistantEach.whoFrenchMin.responderPop);
        
        if (matchButton) {
            make.left.equalTo(self.view.mas_centerX).offset(DistantEach.whoFrenchMin.scoreTriple);
        } else {
            make.left.equalTo(self.view).offset(DistantEach.whoFrenchMin.responderPop);
        }
        make.height.mas_equalTo(DistantEach.whoFrenchMin.eggGathering);
    }];
    
    beatMixView.selectedSegmentIndex = 0;
    [self eulerProgress:beatMixView];
}

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

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

- (void)subtractMealInspiredTwistFireText:(NSInteger)type {
    NSString *bestCeltic = nil;
    UIView *contentView = nil;
    bestCeltic = type == 0 ? [DistantEach thatPrivilegeSlabOperatingSlavic]:[DistantEach catMindVerifyConfirmBrand];
    contentView = type == 0 ? self.editorDecodingDocumentsOffPresence:self.oddWasLeadRootDue;
    
    if (bestCeltic.penBiotinIts) {
        return;
    }
    
    if ([[bestCeltic pathExtension] containsString:DistantEach.whoFrenchMin.polarArtOperationFaxReturns]) {
        UITextView *wonView = (UITextView *)contentView;
        if (wonView.text.length > 0) {
            return;
        }

        
        [MapLicenseView awakeEastStopView:contentView];

        
        NSURL *url = [NSURL URLWithString:bestCeltic];
        NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:url
                                                                 completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
            
            dispatch_async(dispatch_get_main_queue(), ^{
                
                [MapLicenseView variationMenOffsetsLawPartiallyView:contentView];
                
                if (error || data.length == 0) {
                    
                    wonView.text = DistantEach.earMayTopModel.sequencerMantissaEnglishPlainRandomMinimal;
                    return;
                }
                
                
                NSString *canEjectInner = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
                wonView.text = canEjectInner ?: DistantEach.earMayTopModel.fixingFloatUnlockTapNetMattingYoungest;
            });
        }];
        
        [task resume];

    }else {
        WKWebView *arabic = (WKWebView *)contentView;
        if (!arabic.isLoading && arabic.estimatedProgress == 1) {
            [MapLicenseView variationMenOffsetsLawPartiallyView:contentView];
            return;
        }
        [MapLicenseView awakeEastStopView:contentView];
        NSString *boxUnwrap =  [bestCeltic.providersPasswordsJouleMainHeaderCrop stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
        NSURL *url = [NSURL URLWithString:boxUnwrap];
        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:15.0];
        [arabic loadRequest:request];
    }
}

- (void)historyButBundleSplitSnapSkipped:(id)sender {
    [self splitMajorGloballyPositionsHandlingAction:nil];
    if (self.herJobSignerInfoBand) {
        self.herJobSignerInfoBand(NO);
    }
}

- (void)localizesFallbackTomorrowDiacriticCousinAny:(id)sender {
    [self splitMajorGloballyPositionsHandlingAction:nil];
    if (self.herJobSignerInfoBand) {
        self.herJobSignerInfoBand(YES);
    }
}

- (UIView *)delayedEndView:(NSString *)string {
    UIView *rhythmDraft = nil;
    if ([[string pathExtension] containsString:DistantEach.whoFrenchMin.polarArtOperationFaxReturns]) {
        UITextView * retHuman = [UITextView new];
        retHuman.editable = NO;
        retHuman.backgroundColor = UIColor.whiteColor;
        retHuman.textColor = UIColor.grayColor;
        rhythmDraft = retHuman;
    }else {
        WKWebView *visualGrade = [[WKWebView alloc] initWithFrame:CGRectZero];
        visualGrade.backgroundColor = UIColor.clearColor;
        visualGrade.scrollView.backgroundColor = UIColor.lightGrayColor;
        visualGrade.opaque = YES;
        visualGrade.scrollView.bounces =NO;
        visualGrade.scrollView.showsVerticalScrollIndicator = NO;
        visualGrade.scrollView.showsHorizontalScrollIndicator = NO;
        visualGrade.navigationDelegate = self;
        rhythmDraft = visualGrade;
    }
    return rhythmDraft;
}

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

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

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

@end
