

#import "AloneViewController.h"
#import "Shake.h"
#import "ElderDescribesYoungerClampBadgeArm.h"
#import "CervicalMixCharBinaryMin.h"
#import "BagSpecifyConfig.h"

@interface AloneViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) ElderDescribesYoungerClampBadgeArm *notifiedIntentStoodKilogramsModule;
@property (nonatomic, strong) CervicalMixCharBinaryMin *slovakFillApertureDrainAnimator;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static CervicalMixCharBinaryMin *retOfficialStylusCardioidUsageEmbedding = nil;
static ElderDescribesYoungerClampBadgeArm *infiniteSigningExpandingAskTraitGet = nil;

@implementation AloneViewController

+ (void)midDashSave {
    
    [Shake hostDividerAreCelticColoredGray];

    infiniteSigningExpandingAskTraitGet = [[ElderDescribesYoungerClampBadgeArm alloc] init];
    infiniteSigningExpandingAskTraitGet.sumCarLevel = CreditCadenceHusbandPoolBlustery;

    [Shake settingsEndsChangeSpokenSearch:infiniteSigningExpandingAskTraitGet];

    retOfficialStylusCardioidUsageEmbedding = [[CervicalMixCharBinaryMin alloc] init];
    retOfficialStylusCardioidUsageEmbedding.sumCarLevel = QueuePushZero;
    retOfficialStylusCardioidUsageEmbedding.yetWait = 7;
    retOfficialStylusCardioidUsageEmbedding.topTenLinkageIssueFiber = YES;
    [Shake settingsEndsChangeSpokenSearch:retOfficialStylusCardioidUsageEmbedding];

    [retOfficialStylusCardioidUsageEmbedding showDropVerify];
}

+ (CervicalMixCharBinaryMin *)closestCubicTemporaryCatGetExtents {
    return retOfficialStylusCardioidUsageEmbedding;
}
+ (ElderDescribesYoungerClampBadgeArm *)digitThreadsWayOptPaddlePremature {
    return infiniteSigningExpandingAskTraitGet;
}

- (ElderDescribesYoungerClampBadgeArm *)notifiedIntentStoodKilogramsModule {
    return infiniteSigningExpandingAskTraitGet;
}

+ (void)showFromViewController:(UIViewController *)parentVC {
    AloneViewController *click = [[AloneViewController alloc] init];
    UINavigationController *sub = [[UINavigationController alloc] initWithRootViewController:click];
    sub.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:sub animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = sinTextMany.raceMakeGenreUndoneAnyHebrew;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(pickAndAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(adobeAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(yetYetRuleAction)]
    ];
    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.slovakFillApertureDrainAnimator = [AloneViewController closestCubicTemporaryCatGetExtents];

    [self itsChild];
}

- (void)itsChild {
    if (!self.slovakFillApertureDrainAnimator) {
        _textView.text = sinTextMany.lyricistBurnResponderImmediateConjugateHurricane;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.slovakFillApertureDrainAnimator ironContextDate:self.selectedDate];
        } else {
            logs = [self.slovakFillApertureDrainAnimator loseHellman];
        }

        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 = sinTextMany.numbersLingerSentWarningTryVowel;
            }

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

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

- (void)pickAndAction {
    [self itsChild];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *midBasque = [[NSDateFormatter alloc] init];
        midBasque.dateFormat = sinTextMany.categorySunStaySignExceededSemanticHis;
        NSString *tagRegions = [midBasque stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = sinTextMany.theInterruptBridgeLateOriginsFormat;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = sinTextMany.sayFemaleSayPinchStrideHisIntrinsic;
        } else {
            self.title = tagRegions;
        }
    } else {
        self.title = sinTextMany.halfAllowCloseExtentsNonceFirst;
    }
}

- (void)yetYetRuleAction {
    if (!self.slovakFillApertureDrainAnimator) {
        return;
    }

    NSArray<NSDate *> *embeddedCommon = [self.slovakFillApertureDrainAnimator titleDigest];
    if (embeddedCommon.count == 0) {
        UIAlertController *birth = [UIAlertController alertControllerWithTitle:sinTextMany.bedSnapLittleBadPasswordChapter
                                                                       message:sinTextMany.numbersLingerSentWarningTryVowel
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [birth addAction:[UIAlertAction actionWithTitle:sinTextMany.sleepSentencePassVortexThiaminBlob style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:birth animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:sinTextMany.exitsPairUtilityCountMoodSobEnglish
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:sinTextMany.halfAllowCloseExtentsNonceFirst
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self itsChild];
    }]];

    NSDateFormatter *midBasque = [[NSDateFormatter alloc] init];
    midBasque.dateFormat = sinTextMany.categorySunStaySignExceededSemanticHis;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in embeddedCommon) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = sinTextMany.theInterruptBridgeLateOriginsFormat;
        } else if ([calendar isDateInYesterday:date]) {
            title = sinTextMany.sayFemaleSayPinchStrideHisIntrinsic;
        } else {
            title = [midBasque stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:sinTextMany.flashRecentFactoryItemLargeInfinity style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)adobeAction {
    if (!self.slovakFillApertureDrainAnimator) {
        return;
    }

    NSArray *totalOut = [self.slovakFillApertureDrainAnimator butAloneBed];
    if (totalOut.count == 0) {
        UIAlertController *birth = [UIAlertController alertControllerWithTitle:sinTextMany.bedSnapLittleBadPasswordChapter
                                                                       message:sinTextMany.encryptSubmitRequireDividingReliableMaker
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [birth addAction:[UIAlertAction actionWithTitle:sinTextMany.sleepSentencePassVortexThiaminBlob style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:birth animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:sinTextMany.ironMaxCatDatabasesSideSaturateIntegrity
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:sinTextMany.europeanBezelSelfTamilImpactReversesBond
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self talkRadioSee];
    }]];

    for (NSURL *fileURL in totalOut) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:sinTextMany.gurationStylisticEntryKilogramMuteColumnsLaunching, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self buddhistFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:sinTextMany.flashRecentFactoryItemLargeInfinity style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)talkRadioSee {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *eyeGrow = [self.slovakFillApertureDrainAnimator tipCatKindBlur];

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

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

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

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

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

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

@end
