

#import "CheckViewController.h"
#import "Clear.h"
#import "HintTelephoneVeryTraveledElevenMirroring.h"
#import "AdaptorDidLinkAssetStart.h"
#import "HostSoccerConfig.h"

@interface CheckViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) HintTelephoneVeryTraveledElevenMirroring *initiatedDrumCutHigherPrepared;
@property (nonatomic, strong) AdaptorDidLinkAssetStart *putFormLowSwipeFixing;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static AdaptorDidLinkAssetStart *cardSortRefreshedBigTurkmenOur = nil;
static HintTelephoneVeryTraveledElevenMirroring *symbolsKilogramCheckoutTwoMetricsTorque = nil;

@implementation CheckViewController

+ (void)activePoint {
    
    [Clear anyDaysEllipsisBetterPrintRet];

    symbolsKilogramCheckoutTwoMetricsTorque = [[HintTelephoneVeryTraveledElevenMirroring alloc] init];
    symbolsKilogramCheckoutTwoMetricsTorque.addSumLevel = ComparedFunctionsKeyMovieUnload;

    [Clear laterForbidGaspSceneShow:symbolsKilogramCheckoutTwoMetricsTorque];

    cardSortRefreshedBigTurkmenOur = [[AdaptorDidLinkAssetStart alloc] init];
    cardSortRefreshedBigTurkmenOur.addSumLevel = CapCropPanWho;
    cardSortRefreshedBigTurkmenOur.liftPop = 7;
    cardSortRefreshedBigTurkmenOur.subgroupsSkinAreProfileOffer = YES;
    [Clear laterForbidGaspSceneShow:cardSortRefreshedBigTurkmenOur];

    [cardSortRefreshedBigTurkmenOur iterationYears];
}

+ (AdaptorDidLinkAssetStart *)authorityYearsBackAccordingGeneratesAdvisory {
    return cardSortRefreshedBigTurkmenOur;
}
+ (HintTelephoneVeryTraveledElevenMirroring *)thirteenSindhiRetainedPlayZipImage {
    return symbolsKilogramCheckoutTwoMetricsTorque;
}

- (HintTelephoneVeryTraveledElevenMirroring *)initiatedDrumCutHigherPrepared {
    return symbolsKilogramCheckoutTwoMetricsTorque;
}

+ (void)fetchJobViewController:(UIViewController *)parentVC {
    CheckViewController *might = [[CheckViewController alloc] init];
    UINavigationController *say = [[UINavigationController alloc] initWithRootViewController:might];
    say.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:say animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = sugarDidRet.indianGrowWakeRunningStereoKilograms;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]
                                            initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
                                            target:self
                                            action:@selector(cycleAction)];

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(oneHoldAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(solidAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(cascadeSawAction)]
    ];
    self.navigationController.navigationBar.layoutMargins = UIEdgeInsetsMake(0, 0, 0, -10);

    _textView = [[UITextView alloc] init];
    _textView.font = [UIFont systemFontOfSize:11];
    _textView.editable = NO;
    _textView.backgroundColor = [UIColor systemBackgroundColor];
    _textView.textColor = [UIColor labelColor];
    _textView.translatesAutoresizingMaskIntoConstraints = NO;
    _textView.showsVerticalScrollIndicator = YES;
    _textView.showsHorizontalScrollIndicator = YES;
    _textView.alwaysBounceVertical = YES;
    
    _textView.scrollEnabled = YES;
    [self.view addSubview:_textView];

    [NSLayoutConstraint activateConstraints:@[
        [_textView.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor],
        [_textView.leadingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.leadingAnchor constant:8],
        [_textView.trailingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.trailingAnchor constant:-8],
        [_textView.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor]
    ]];

    self.putFormLowSwipeFixing = [CheckViewController authorityYearsBackAccordingGeneratesAdvisory];

    [self pubState];
}

- (void)pubState {
    if (!self.putFormLowSwipeFixing) {
        _textView.text = sugarDidRet.functionsAmericanTextureMeasuredListenerPrep;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.putFormLowSwipeFixing tiedOperandDate:self.selectedDate];
        } else {
            logs = [self.putFormLowSwipeFixing tagPastWord];
        }

        dispatch_async(dispatch_get_main_queue(), ^{
            if (logs.length > 0) {
                self.textView.text = logs;
                
                [self.textView scrollRangeToVisible:NSMakeRange(logs.length - 1, 1)];
            } else {
                self.textView.text = sugarDidRet.preciseHitReadySalientPolarAffine;
            }

            [self updateTitle];
        });
    });
}

- (void)cycleAction {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)oneHoldAction {
    [self pubState];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *menuFiber = [[NSDateFormatter alloc] init];
        menuFiber.dateFormat = sugarDidRet.centersLiveGroupCaloriesSwapCompoundReady;
        NSString *twelveSnow = [menuFiber stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = sugarDidRet.fitChunkyMarkCervicalRegisterDesktop;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = sugarDidRet.peerAttachExtendTrustBlendResponsesHis;
        } else {
            self.title = twelveSnow;
        }
    } else {
        self.title = sugarDidRet.slabNominalSoftwareExpirePutKernel;
    }
}

- (void)cascadeSawAction {
    if (!self.putFormLowSwipeFixing) {
        return;
    }

    NSArray<NSDate *> *stormAssertion = [self.putFormLowSwipeFixing illHoldInfo];
    if (stormAssertion.count == 0) {
        UIAlertController *metal = [UIAlertController alertControllerWithTitle:sugarDidRet.joiningAtomGigabitsAllocatedAcceptingRet
                                                                       message:sugarDidRet.preciseHitReadySalientPolarAffine
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [metal addAction:[UIAlertAction actionWithTitle:sugarDidRet.popPivotEncodedFrictionNorthRule style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:metal animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:sugarDidRet.dublinBlockValidityClampMightShortcutsConflict
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:sugarDidRet.slabNominalSoftwareExpirePutKernel
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self pubState];
    }]];

    NSDateFormatter *menuFiber = [[NSDateFormatter alloc] init];
    menuFiber.dateFormat = sugarDidRet.centersLiveGroupCaloriesSwapCompoundReady;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in stormAssertion) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = sugarDidRet.fitChunkyMarkCervicalRegisterDesktop;
        } else if ([calendar isDateInYesterday:date]) {
            title = sugarDidRet.peerAttachExtendTrustBlendResponsesHis;
        } else {
            title = [menuFiber stringFromDate:date];
        }

        [actionSheet addAction:[UIAlertAction actionWithTitle:title
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            self.selectedDate = date;
            [self pubState];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:sugarDidRet.gregorianStrokedDecreasePenUnderageAdopt style:UIAlertActionStyleCancel handler:nil]];

    if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
        actionSheet.popoverPresentationController.barButtonItem = self.navigationItem.rightBarButtonItems.lastObject;
    }

    [self presentViewController:actionSheet animated:YES completion:nil];
}

- (void)solidAction {
    if (!self.putFormLowSwipeFixing) {
        return;
    }

    NSArray *phoneEar = [self.putFormLowSwipeFixing slopeAspect];
    if (phoneEar.count == 0) {
        UIAlertController *metal = [UIAlertController alertControllerWithTitle:sugarDidRet.joiningAtomGigabitsAllocatedAcceptingRet
                                                                       message:sugarDidRet.oldLittleSubtractDependingDogHalf
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [metal addAction:[UIAlertAction actionWithTitle:sugarDidRet.popPivotEncodedFrictionNorthRule style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:metal animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:sugarDidRet.unwrapChromaticWarnSerbianScheduledEdgePreparing
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:sugarDidRet.sawControlsFrameStandardRestartPostalProblem
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self calendarZone];
    }]];

    for (NSURL *fileURL in phoneEar) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:sugarDidRet.quoteRenderedAlignDeliveredRetainSixPost, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self breakingFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:sugarDidRet.gregorianStrokedDecreasePenUnderageAdopt style:UIAlertActionStyleCancel handler:nil]];

    if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
        actionSheet.popoverPresentationController.barButtonItem = self.navigationItem.rightBarButtonItems.lastObject;
    }

    [self presentViewController:actionSheet animated:YES completion:nil];
}

- (void)calendarZone {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *editShe = [self.putFormLowSwipeFixing terminateCover];

        dispatch_async(dispatch_get_main_queue(), ^{
            if (editShe.length > 0) {
                UIActivityViewController *bikeRecord = [[UIActivityViewController alloc]
                                                       initWithActivityItems:@[editShe]
                                                       applicationActivities:nil];

                if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
                    bikeRecord.popoverPresentationController.barButtonItem = self.navigationItem.rightBarButtonItems.lastObject;
                }

                [self presentViewController:bikeRecord animated:YES completion:nil];
            }
        });
    });
}

- (void)breakingFile:(NSURL *)fileURL {
    UIActivityViewController *bikeRecord = [[UIActivityViewController alloc]
                                           initWithActivityItems:@[fileURL]
                                           applicationActivities:nil];

    if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
        bikeRecord.popoverPresentationController.barButtonItem = self.navigationItem.rightBarButtonItems.lastObject;
    }

    [self presentViewController:bikeRecord animated:YES completion:nil];
}

@end
