

#import "AlphaViewController.h"
#import "Visit.h"
#import "MaximumSwedishProducedAirAzimuthExact.h"
#import "CauseLanguageSoundSkippedWay.h"
#import "BringEvictConfig.h"

@interface AlphaViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) MaximumSwedishProducedAirAzimuthExact *blackCentralsSecondaryEndWord;
@property (nonatomic, strong) CauseLanguageSoundSkippedWay *mostlyProducedSpecifierFixScrolled;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static CauseLanguageSoundSkippedWay *performsExitsHoursJustifiedRetainFinger = nil;
static MaximumSwedishProducedAirAzimuthExact *expandingWhoOrderOrdinalAlbanianLate = nil;

@implementation AlphaViewController

+ (void)tapEntryLog {
    
    [Visit separateKilometerWalkingSpeakingPlateDrop];

    expandingWhoOrderOrdinalAlbanianLate = [[MaximumSwedishProducedAirAzimuthExact alloc] init];
    expandingWhoOrderOrdinalAlbanianLate.kinOptLevel = BitPluralThousandsSaveSlight;

    [Visit blinkNotTextChannelsDetector:expandingWhoOrderOrdinalAlbanianLate];

    performsExitsHoursJustifiedRetainFinger = [[CauseLanguageSoundSkippedWay alloc] init];
    performsExitsHoursJustifiedRetainFinger.kinOptLevel = RealPinMixDay;
    performsExitsHoursJustifiedRetainFinger.eyeIdle = 7;
    performsExitsHoursJustifiedRetainFinger.programCinematicPreferWorkoutsVector = YES;
    [Visit blinkNotTextChannelsDetector:performsExitsHoursJustifiedRetainFinger];

    [performsExitsHoursJustifiedRetainFinger peerWeightFade];
}

+ (CauseLanguageSoundSkippedWay *)genericsSupplyEarRestartCallShe {
    return performsExitsHoursJustifiedRetainFinger;
}
+ (MaximumSwedishProducedAirAzimuthExact *)kernelsEyeBelowForkExtendingBookmark {
    return expandingWhoOrderOrdinalAlbanianLate;
}

- (MaximumSwedishProducedAirAzimuthExact *)blackCentralsSecondaryEndWord {
    return expandingWhoOrderOrdinalAlbanianLate;
}

+ (void)denseEndViewController:(UIViewController *)parentVC {
    AlphaViewController *cocoa = [[AlphaViewController alloc] init];
    UINavigationController *her = [[UINavigationController alloc] initWithRootViewController:cocoa];
    her.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:her animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = commitEvict.nameUplinkTagCollapseSupplyLaunch;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(mapJustAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(solidAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(tryFitSinkAction)]
    ];
    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.mostlyProducedSpecifierFixScrolled = [AlphaViewController genericsSupplyEarRestartCallShe];

    [self stakeHow];
}

- (void)stakeHow {
    if (!self.mostlyProducedSpecifierFixScrolled) {
        _textView.text = commitEvict.invokeSmoothedPaperVitaminRaceIndirect;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.mostlyProducedSpecifierFixScrolled bypassQuietDate:self.selectedDate];
        } else {
            logs = [self.mostlyProducedSpecifierFixScrolled regionsSave];
        }

        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 = commitEvict.elevenVelocityGenderAllowRareElder;
            }

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

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

- (void)mapJustAction {
    [self stakeHow];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *energyJob = [[NSDateFormatter alloc] init];
        energyJob.dateFormat = commitEvict.cancelingOutlineHelloButFindJabberCollected;
        NSString *resultsMin = [energyJob stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = commitEvict.managerReachableSinIncorrectUighurSwimming;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = commitEvict.baseBoxLocalesAdditionMidAmbientUnion;
        } else {
            self.title = resultsMin;
        }
    } else {
        self.title = commitEvict.summariesTheSoundRedRemovableAbout;
    }
}

- (void)tryFitSinkAction {
    if (!self.mostlyProducedSpecifierFixScrolled) {
        return;
    }

    NSArray<NSDate *> *autoCourseEdga = [self.mostlyProducedSpecifierFixScrolled easyOldLook];
    if (autoCourseEdga.count == 0) {
        UIAlertController *radio = [UIAlertController alertControllerWithTitle:commitEvict.maleInitiatedPartiallyFindBigIssuer
                                                                       message:commitEvict.elevenVelocityGenderAllowRareElder
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [radio addAction:[UIAlertAction actionWithTitle:commitEvict.spotlightButAcrossSomaliPivotSequences style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:radio animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:commitEvict.zeroInnerBoundaryBundleReliableCropTree
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:commitEvict.summariesTheSoundRedRemovableAbout
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self stakeHow];
    }]];

    NSDateFormatter *energyJob = [[NSDateFormatter alloc] init];
    energyJob.dateFormat = commitEvict.cancelingOutlineHelloButFindJabberCollected;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in autoCourseEdga) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = commitEvict.managerReachableSinIncorrectUighurSwimming;
        } else if ([calendar isDateInYesterday:date]) {
            title = commitEvict.baseBoxLocalesAdditionMidAmbientUnion;
        } else {
            title = [energyJob stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:commitEvict.plainSundaneseLongitudeEpisodeMixSum 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.mostlyProducedSpecifierFixScrolled) {
        return;
    }

    NSArray *senseAsk = [self.mostlyProducedSpecifierFixScrolled askWasLoops];
    if (senseAsk.count == 0) {
        UIAlertController *radio = [UIAlertController alertControllerWithTitle:commitEvict.maleInitiatedPartiallyFindBigIssuer
                                                                       message:commitEvict.policyFollowerEncipherHigherLayoutDiagnose
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [radio addAction:[UIAlertAction actionWithTitle:commitEvict.spotlightButAcrossSomaliPivotSequences style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:radio animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:commitEvict.prefixShadowToneHeadPingBirthdayOffset
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:commitEvict.relationsBreakGaspPlayEventualEqualityComposer
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self oddLazySmile];
    }]];

    for (NSURL *fileURL in senseAsk) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:commitEvict.zipVerticalSegmentConvertedBarReloadRain, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self chromiumFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:commitEvict.plainSundaneseLongitudeEpisodeMixSum style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)oddLazySmile {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *ropeHow = [self.mostlyProducedSpecifierFixScrolled yetTrialWhoPin];

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

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

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

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

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

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

@end
