

#import "AlertViewController.h"
#import "Angle.h"
#import "EuropeanCropTagsMoleDescribesExpired.h"
#import "MessagingBengaliLiteralAttributeMagic.h"
#import "CountPulseConfig.h"

@interface AlertViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) EuropeanCropTagsMoleDescribesExpired *speakComputerCroppingIterationCaptures;
@property (nonatomic, strong) MessagingBengaliLiteralAttributeMagic *dailyKeepAnalysisParentalAsleep;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static MessagingBengaliLiteralAttributeMagic *forbiddenBitsDismissTraitEncipherExpand = nil;
static EuropeanCropTagsMoleDescribesExpired *polarIrishDispatchColumnAllocatedLimit = nil;

@implementation AlertViewController

+ (void)oldSpectral {
    
    [Angle youngerHexCommentsFoodDisablingProduced];

    polarIrishDispatchColumnAllocatedLimit = [[EuropeanCropTagsMoleDescribesExpired alloc] init];
    polarIrishDispatchColumnAllocatedLimit.minuteLevel = ImagePrologLengthEqualSolid;

    [Angle clampingClockWayCelticDesigner:polarIrishDispatchColumnAllocatedLimit];

    forbiddenBitsDismissTraitEncipherExpand = [[MessagingBengaliLiteralAttributeMagic alloc] init];
    forbiddenBitsDismissTraitEncipherExpand.minuteLevel = WarpWidthLine;
    forbiddenBitsDismissTraitEncipherExpand.chinese = 7;
    forbiddenBitsDismissTraitEncipherExpand.selectionSiblingsShipmentDescentMen = YES;
    [Angle clampingClockWayCelticDesigner:forbiddenBitsDismissTraitEncipherExpand];

    [forbiddenBitsDismissTraitEncipherExpand turnFitFitTake];
}

+ (MessagingBengaliLiteralAttributeMagic *)browseCupExhaustedPartiallyMustOfficial {
    return forbiddenBitsDismissTraitEncipherExpand;
}
+ (EuropeanCropTagsMoleDescribesExpired *)execReturnedThumbDefinedVariationTeaspoons {
    return polarIrishDispatchColumnAllocatedLimit;
}

- (EuropeanCropTagsMoleDescribesExpired *)speakComputerCroppingIterationCaptures {
    return polarIrishDispatchColumnAllocatedLimit;
}

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

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = flightSurge.placementDistanceSugarFeedbackAnonymousDaughter;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(ellipseAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(molarAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(minItalianAction)]
    ];
    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.dailyKeepAnalysisParentalAsleep = [AlertViewController browseCupExhaustedPartiallyMustOfficial];

    [self receives];
}

- (void)receives {
    if (!self.dailyKeepAnalysisParentalAsleep) {
        _textView.text = flightSurge.entitiesSyntaxTapTaskOwnTickets;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.dailyKeepAnalysisParentalAsleep liftPronounDate:self.selectedDate];
        } else {
            logs = [self.dailyKeepAnalysisParentalAsleep useClaimEgg];
        }

        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 = flightSurge.meteringTailUptimeWidgetAssistantCircular;
            }

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

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

- (void)ellipseAction {
    [self receives];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *eggReveal = [[NSDateFormatter alloc] init];
        eggReveal.dateFormat = flightSurge.notAssumeBadGramProgressAudiogramContrast;
        NSString *pingAssign = [eggReveal stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = flightSurge.realLaunchedNotifyLogAuthorAcquire;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = flightSurge.subDiscreteAppendVolatileLeakyAsteriskObservers;
        } else {
            self.title = pingAssign;
        }
    } else {
        self.title = flightSurge.pintPartialCubeStatementDustSlice;
    }
}

- (void)minItalianAction {
    if (!self.dailyKeepAnalysisParentalAsleep) {
        return;
    }

    NSArray<NSDate *> *listMarginMale = [self.dailyKeepAnalysisParentalAsleep cubicCursor];
    if (listMarginMale.count == 0) {
        UIAlertController *learn = [UIAlertController alertControllerWithTitle:flightSurge.tryIndentPinArbiterBigTone
                                                                       message:flightSurge.meteringTailUptimeWidgetAssistantCircular
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [learn addAction:[UIAlertAction actionWithTitle:flightSurge.duePhoneAlbumFitBaseClose style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:learn animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:flightSurge.assistiveBestWasForwardStrictPlugAxial
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:flightSurge.pintPartialCubeStatementDustSlice
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self receives];
    }]];

    NSDateFormatter *eggReveal = [[NSDateFormatter alloc] init];
    eggReveal.dateFormat = flightSurge.notAssumeBadGramProgressAudiogramContrast;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in listMarginMale) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = flightSurge.realLaunchedNotifyLogAuthorAcquire;
        } else if ([calendar isDateInYesterday:date]) {
            title = flightSurge.subDiscreteAppendVolatileLeakyAsteriskObservers;
        } else {
            title = [eggReveal stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:flightSurge.seleniumSyntaxPongMoleYardDisabled style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)molarAction {
    if (!self.dailyKeepAnalysisParentalAsleep) {
        return;
    }

    NSArray *equalSaw = [self.dailyKeepAnalysisParentalAsleep bagCheckout];
    if (equalSaw.count == 0) {
        UIAlertController *learn = [UIAlertController alertControllerWithTitle:flightSurge.tryIndentPinArbiterBigTone
                                                                       message:flightSurge.bounceHitMantissaCommonScheduledPart
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [learn addAction:[UIAlertAction actionWithTitle:flightSurge.duePhoneAlbumFitBaseClose style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:learn animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:flightSurge.tripleFairBottomSynthesisAreaDownloadCardioid
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:flightSurge.columnCharacterLaunchPreferredLiterOutputReader
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self wideFunEmpty];
    }]];

    for (NSURL *fileURL in equalSaw) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:flightSurge.arteryAdoptCardioidChangingKnowOffAnd, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self turnHaveFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:flightSurge.seleniumSyntaxPongMoleYardDisabled style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)wideFunEmpty {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *adaptor = [self.dailyKeepAnalysisParentalAsleep adverbCriteria];

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

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

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

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

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

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

@end
